00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00021
00022 #ifndef NET_INSTAWEB_HTTP_PUBLIC_FAKE_URL_ASYNC_FETCHER_H_
00023 #define NET_INSTAWEB_HTTP_PUBLIC_FAKE_URL_ASYNC_FETCHER_H_
00024
00025 #include "net/instaweb/http/public/url_async_fetcher.h"
00026 #include "net/instaweb/http/public/url_fetcher.h"
00027 #include "net/instaweb/http/public/url_pollable_async_fetcher.h"
00028 #include "net/instaweb/util/public/basictypes.h"
00029 #include "net/instaweb/util/public/string.h"
00030
00031 namespace net_instaweb {
00032
00033 class MessageHandler;
00034 class RequestHeaders;
00035 class ResponseHeaders;
00036 class Writer;
00037
00044 class FakeUrlAsyncFetcher : public UrlPollableAsyncFetcher {
00045 public:
00046 explicit FakeUrlAsyncFetcher(UrlFetcher* url_fetcher)
00047 : url_fetcher_(url_fetcher),
00048 fetcher_supports_https_(true) {
00049 }
00050 virtual ~FakeUrlAsyncFetcher();
00051
00052 virtual bool SupportsHttps() const { return fetcher_supports_https_; }
00053
00054 virtual bool StreamingFetch(const GoogleString& url,
00055 const RequestHeaders& request_headers,
00056 ResponseHeaders* response_headers,
00057 Writer* writer,
00058 MessageHandler* handler,
00059 Callback* callback) {
00060 bool ret = url_fetcher_->StreamingFetchUrl(
00061 url, request_headers, response_headers, writer, handler);
00062 callback->Done(ret);
00063 return true;
00064 }
00065
00068 virtual int Poll(int64 max_wait_ms) { return 0; }
00069
00070 void set_fetcher_supports_https(bool val) { fetcher_supports_https_ = val; }
00071
00072 private:
00073 UrlFetcher* url_fetcher_;
00074 bool fetcher_supports_https_;
00075
00076 DISALLOW_COPY_AND_ASSIGN(FakeUrlAsyncFetcher);
00077 };
00078
00079 }
00080
00081 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_FAKE_URL_ASYNC_FETCHER_H_