Page Speed Optimization Libraries  1.4.26.1
net/instaweb/automatic/public/proxy_interface.h
Go to the documentation of this file.
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       bool* added_page_property_callback = NULL);
00089 
00090  private:
00091   friend class ProxyInterfaceTest;
00092 
00096   void ProxyRequest(bool is_resource_fetch,
00097                     const GoogleUrl& requested_url,
00098                     AsyncFetch* async_fetch,
00099                     MessageHandler* handler);
00100 
00103   bool UrlAndPortMatchThisServer(const GoogleUrl& url);
00104 
00106   ServerContext* server_context_; 
00107   UrlAsyncFetcher* fetcher_; 
00108   Timer* timer_; 
00109   MessageHandler* handler_; 
00110 
00114   const GoogleString hostname_;
00115   const int port_;
00116 
00119   TimedVariable* all_requests_;
00121   TimedVariable* pagespeed_requests_;
00123   TimedVariable* blink_requests_;
00125   TimedVariable* blink_critical_line_requests_;
00127   TimedVariable* rejected_requests_;
00128 
00129   scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
00130 
00131   DISALLOW_COPY_AND_ASSIGN(ProxyInterface);
00132 };
00133 
00134 }  
00135 
00136 #endif  ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines