00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00023
00024 #ifndef NET_INSTAWEB_HTTP_PUBLIC_URL_ASYNC_FETCHER_H_
00025 #define NET_INSTAWEB_HTTP_PUBLIC_URL_ASYNC_FETCHER_H_
00026
00027 #include "net/instaweb/util/public/basictypes.h"
00028 #include "net/instaweb/util/public/string.h"
00029
00030 namespace net_instaweb {
00031
00032 class AsyncFetch;
00033 class MessageHandler;
00034 class RequestHeaders;
00035 class ResponseHeaders;
00036 class Writer;
00037
00038 class UrlAsyncFetcher {
00039 public:
00040 static const int64 kUnspecifiedTimeout;
00041
00043 static const char kStatisticsGroup[];
00044
00045 class Callback {
00046 public:
00047 Callback() : modified_(true) {}
00048 virtual ~Callback();
00049 virtual void Done(bool success) = 0;
00050
00053 virtual bool EnableThreaded() const;
00054
00056 void set_modified(bool modified) { modified_ = modified; }
00057 bool modified() const { return modified_; }
00058
00059 private:
00064 bool modified_;
00065 };
00066
00067 virtual ~UrlAsyncFetcher();
00068
00071 virtual bool SupportsHttps() const { return true; }
00072
00087 virtual bool StreamingFetch(const GoogleString& url,
00088 const RequestHeaders& request_headers,
00089 ResponseHeaders* response_headers,
00090 Writer* response_writer,
00091 MessageHandler* message_handler,
00092 Callback* callback);
00093
00106 virtual bool Fetch(const GoogleString& url,
00107 MessageHandler* message_handler,
00108 AsyncFetch* fetch);
00109
00114 virtual bool ConditionalFetch(const GoogleString& url,
00115 int64 if_modified_since_ms,
00116 const RequestHeaders& request_headers,
00117 ResponseHeaders* response_headers,
00118 Writer* response_writer,
00119 MessageHandler* message_handler,
00120 Callback* callback);
00121
00124 virtual int64 timeout_ms() { return kUnspecifiedTimeout; }
00125
00130 virtual void ShutDown();
00131
00134 void set_fetch_with_gzip(bool x) { fetch_with_gzip_ = x; }
00135 bool fetch_with_gzip() const { return fetch_with_gzip_; }
00136
00139 AsyncFetch* EnableInflation(AsyncFetch* fetch) const;
00140
00141 protected:
00144 UrlAsyncFetcher() : fetch_with_gzip_(false) {}
00145
00146 private:
00147 bool fetch_with_gzip_;
00148
00149 DISALLOW_COPY_AND_ASSIGN(UrlAsyncFetcher);
00150 };
00151
00152 }
00153
00154 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_URL_ASYNC_FETCHER_H_