Page Speed Optimization Libraries
1.2.24.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 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 class Timer; 00048 00050 class ProxyInterface : public UrlAsyncFetcher { 00051 public: 00052 ProxyInterface(const StringPiece& hostname, int port, 00053 ServerContext* manager, Statistics* stats); 00054 virtual ~ProxyInterface(); 00055 00057 static void InitStats(Statistics* statistics); 00058 00062 virtual void Fetch(const GoogleString& requested_url, 00063 MessageHandler* handler, 00064 AsyncFetch* async_fetch); 00065 00068 void ProxyRequestCallback( 00069 bool is_resource_fetch, 00070 GoogleUrl* request_url, 00071 AsyncFetch* async_fetch, 00072 RewriteOptions* domain_options, 00073 RewriteOptions* query_options, 00074 MessageHandler* handler); 00075 00077 bool IsWellFormedUrl(const GoogleUrl& url); 00078 00079 static const char kBlinkRequestCount[]; 00080 static const char kBlinkCriticalLineRequestCount[]; 00081 00083 virtual ProxyFetchPropertyCallbackCollector* InitiatePropertyCacheLookup( 00084 bool is_resource_fetch, 00085 const GoogleUrl& request_url, 00086 RewriteOptions* options, 00087 AsyncFetch* async_fetch); 00088 00089 private: 00090 friend class ProxyInterfaceTest; 00091 00095 void ProxyRequest(bool is_resource_fetch, 00096 const GoogleUrl& requested_url, 00097 AsyncFetch* async_fetch, 00098 MessageHandler* handler); 00099 00102 bool UrlAndPortMatchThisServer(const GoogleUrl& url); 00103 00105 ServerContext* server_context_; 00106 UrlAsyncFetcher* fetcher_; 00107 Timer* timer_; 00108 MessageHandler* handler_; 00109 00113 const GoogleString hostname_; 00114 const int port_; 00115 00118 TimedVariable* all_requests_; 00120 TimedVariable* pagespeed_requests_; 00122 TimedVariable* blink_requests_; 00124 TimedVariable* blink_critical_line_requests_; 00126 TimedVariable* rejected_requests_; 00127 00128 scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_; 00129 00130 DISALLOW_COPY_AND_ASSIGN(ProxyInterface); 00131 }; 00132 00133 } 00134 00135 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_