Page Speed Optimization Libraries
1.7.30.3
|
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 00026 00027 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_ 00028 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_ 00029 00030 #include "net/instaweb/http/public/url_async_fetcher.h" 00031 #include "net/instaweb/util/public/basictypes.h" 00032 #include "net/instaweb/util/public/scoped_ptr.h" 00033 #include "net/instaweb/util/public/string.h" 00034 #include "net/instaweb/util/public/string_util.h" 00035 00036 namespace net_instaweb { 00037 00038 class AsyncFetch; 00039 class GoogleUrl; 00040 class MessageHandler; 00041 class ProxyFetchPropertyCallbackCollector; 00042 class ProxyFetchFactory; 00043 class ServerContext; 00044 class RewriteOptions; 00045 class Statistics; 00046 class TimedVariable; 00047 00049 class ProxyInterface : public UrlAsyncFetcher { 00050 public: 00051 ProxyInterface(const StringPiece& hostname, int port, 00052 ServerContext* server_context, Statistics* stats); 00053 virtual ~ProxyInterface(); 00054 00056 static void InitStats(Statistics* statistics); 00057 00061 virtual void Fetch(const GoogleString& requested_url, 00062 MessageHandler* handler, 00063 AsyncFetch* async_fetch); 00064 00066 bool IsWellFormedUrl(const GoogleUrl& url); 00067 00068 static const char kCacheHtmlRequestCount[]; 00069 00071 virtual ProxyFetchPropertyCallbackCollector* InitiatePropertyCacheLookup( 00072 bool is_resource_fetch, 00073 const GoogleUrl& request_url, 00074 RewriteOptions* options, 00075 AsyncFetch* async_fetch, 00076 const bool requires_blink_cohort, 00077 bool* added_page_property_callback); 00078 00079 protected: 00081 ServerContext* server_context_; 00082 00083 private: 00084 friend class ProxyInterfaceTest; 00085 00089 void ProxyRequest(bool is_resource_fetch, 00090 const GoogleUrl& requested_url, 00091 AsyncFetch* async_fetch, 00092 MessageHandler* handler); 00093 00096 struct RequestData; 00097 void GetRewriteOptionsDone(RequestData* request_data, 00098 RewriteOptions* query_options); 00099 00102 bool UrlAndPortMatchThisServer(const GoogleUrl& url); 00103 00107 const GoogleString hostname_; 00108 const int port_; 00109 00112 TimedVariable* all_requests_; 00114 TimedVariable* pagespeed_requests_; 00116 TimedVariable* cache_html_flow_requests_; 00118 TimedVariable* rejected_requests_; 00119 00120 scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_; 00121 00122 DISALLOW_COPY_AND_ASSIGN(ProxyInterface); 00123 }; 00124 00125 } 00126 00127 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_