Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
proxy_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
26 
27 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_
28 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_PROXY_INTERFACE_H_
29 
35 
36 namespace net_instaweb {
37 
38 class AsyncFetch;
39 class GoogleUrl;
40 class MessageHandler;
41 class ProxyFetchPropertyCallbackCollector;
42 class ProxyFetchFactory;
43 class ServerContext;
44 class RewriteOptions;
45 class Statistics;
46 class TimedVariable;
47 
50  public:
51  ProxyInterface(const StringPiece& hostname, int port,
52  ServerContext* server_context, Statistics* stats);
53  virtual ~ProxyInterface();
54 
56  static void InitStats(Statistics* statistics);
57 
61  virtual void Fetch(const GoogleString& requested_url,
62  MessageHandler* handler,
63  AsyncFetch* async_fetch);
64 
66  bool IsWellFormedUrl(const GoogleUrl& url);
67 
68  static const char kCacheHtmlRequestCount[];
69 
72  bool is_resource_fetch,
73  const GoogleUrl& request_url,
74  RewriteOptions* options,
75  AsyncFetch* async_fetch,
76  const bool requires_blink_cohort,
77  bool* added_page_property_callback);
78 
79  protected:
82 
83  private:
84  friend class ProxyInterfaceTest;
85 
89  void ProxyRequest(bool is_resource_fetch,
90  const GoogleUrl& requested_url,
91  AsyncFetch* async_fetch,
92  MessageHandler* handler);
93 
96  struct RequestData;
97  void GetRewriteOptionsDone(RequestData* request_data,
98  RewriteOptions* query_options);
99 
102  bool UrlAndPortMatchThisServer(const GoogleUrl& url);
103 
107  const GoogleString hostname_;
108  const int port_;
109 
112  TimedVariable* all_requests_;
114  TimedVariable* pagespeed_requests_;
116  TimedVariable* cache_html_flow_requests_;
118  TimedVariable* rejected_requests_;
119 
120  scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
121 
122  DISALLOW_COPY_AND_ASSIGN(ProxyInterface);
123 };
124 
125 }
126 
127 #endif
virtual ProxyFetchPropertyCallbackCollector * InitiatePropertyCacheLookup(bool is_resource_fetch, const GoogleUrl &request_url, RewriteOptions *options, AsyncFetch *async_fetch, const bool requires_blink_cohort, bool *added_page_property_callback)
Initiates the PropertyCache look up.
bool IsWellFormedUrl(const GoogleUrl &url)
Is this url_string well-formed enough to proxy through?
virtual void Fetch(const GoogleString &requested_url, MessageHandler *handler, AsyncFetch *async_fetch)
Definition: proxy_interface.h:49
static void InitStats(Statistics *statistics)
Initializes statistics variables associated with this class.
Definition: async_fetch.h:53
Definition: server_context.h:100
Definition: rewrite_options.h:81
ServerContext * server_context_
Needed by subclasses when overriding InitiatePropertyCacheLookup.
Definition: proxy_interface.h:81
Definition: url_async_fetcher.h:33