Page Speed Optimization Libraries
1.3.25.1
|
00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_HTTP_PUBLIC_CACHE_URL_ASYNC_FETCHER_H_ 00020 #define NET_INSTAWEB_HTTP_PUBLIC_CACHE_URL_ASYNC_FETCHER_H_ 00021 00022 #include "net/instaweb/http/public/url_async_fetcher.h" 00023 #include "net/instaweb/util/public/basictypes.h" 00024 #include "net/instaweb/util/public/string.h" 00025 00026 namespace net_instaweb { 00027 00028 class AsyncFetch; 00029 class Histogram; 00030 class HTTPCache; 00031 class MessageHandler; 00032 class Variable; 00033 00049 class CacheUrlAsyncFetcher : public UrlAsyncFetcher { 00050 public: 00051 CacheUrlAsyncFetcher(HTTPCache* cache, UrlAsyncFetcher* fetcher) 00052 : http_cache_(cache), 00053 fetcher_(fetcher), 00054 backend_first_byte_latency_(NULL), 00055 fallback_responses_served_(NULL), 00056 num_conditional_refreshes_(NULL), 00057 respect_vary_(false), 00058 ignore_recent_fetch_failed_(false), 00059 serve_stale_if_fetch_error_(false), 00060 default_cache_html_(false) { 00061 } 00062 virtual ~CacheUrlAsyncFetcher(); 00063 00064 virtual bool SupportsHttps() const { return fetcher_->SupportsHttps(); } 00065 00066 virtual void Fetch(const GoogleString& url, 00067 MessageHandler* message_handler, 00068 AsyncFetch* base_fetch); 00069 00070 HTTPCache* http_cache() const { return http_cache_; } 00071 UrlAsyncFetcher* fetcher() const { return fetcher_; } 00072 00073 void set_backend_first_byte_latency_histogram(Histogram* x) { 00074 backend_first_byte_latency_ = x; 00075 } 00076 00077 Histogram* backend_first_byte_latency_histogram() const { 00078 return backend_first_byte_latency_; 00079 } 00080 00081 void set_fallback_responses_served(Variable* x) { 00082 fallback_responses_served_ = x; 00083 } 00084 00085 Variable* fallback_responses_served() const { 00086 return fallback_responses_served_; 00087 } 00088 00089 void set_num_conditional_refreshes(Variable* x) { 00090 num_conditional_refreshes_ = x; 00091 } 00092 00093 Variable* num_conditional_refreshes() const { 00094 return num_conditional_refreshes_; 00095 } 00096 00097 void set_respect_vary(bool x) { respect_vary_ = x; } 00098 bool respect_vary() const { return respect_vary_; } 00099 00100 void set_ignore_recent_fetch_failed(bool x) { 00101 ignore_recent_fetch_failed_ = x; 00102 } 00103 bool ignore_recent_fetch_failed() const { 00104 return ignore_recent_fetch_failed_; 00105 } 00106 00107 void set_serve_stale_if_fetch_error(bool x) { 00108 serve_stale_if_fetch_error_ = x; 00109 } 00110 00111 bool serve_stale_if_fetch_error() const { 00112 return serve_stale_if_fetch_error_; 00113 } 00114 00115 void set_default_cache_html(bool x) { default_cache_html_ = x; } 00116 bool default_cache_html() const { return default_cache_html_; } 00117 00118 private: 00120 HTTPCache* http_cache_; 00121 UrlAsyncFetcher* fetcher_; 00122 00123 Histogram* backend_first_byte_latency_; 00124 Variable* fallback_responses_served_; 00125 Variable* num_conditional_refreshes_; 00126 00127 bool respect_vary_; 00128 bool ignore_recent_fetch_failed_; 00129 bool serve_stale_if_fetch_error_; 00130 bool default_cache_html_; 00131 00132 DISALLOW_COPY_AND_ASSIGN(CacheUrlAsyncFetcher); 00133 }; 00134 00135 } 00136 00137 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_CACHE_URL_ASYNC_FETCHER_H_