Page Speed Optimization Libraries  1.13.35.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 PAGESPEED_AUTOMATIC_PROXY_INTERFACE_H_
28 #define PAGESPEED_AUTOMATIC_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(StringPiece stats_prefix, StringPiece hostname, int port,
52  ServerContext* server_context, Statistics* stats);
53  virtual ~ProxyInterface();
54 
56  static void InitStats(StringPiece stats_prefix, 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 
77  protected:
80 
81  private:
82  friend class ProxyInterfaceTest;
83 
87  void ProxyRequest(bool is_resource_fetch,
88  const GoogleUrl& requested_url,
89  AsyncFetch* async_fetch,
90  MessageHandler* handler);
91 
94  struct RequestData;
95  void GetRewriteOptionsDone(RequestData* request_data,
96  RewriteOptions* query_options);
97 
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_;
120  TimedVariable* requests_without_domain_config_;
122  TimedVariable* resource_requests_without_domain_config_;
123 
124  scoped_ptr<ProxyFetchFactory> proxy_fetch_factory_;
125 
126 
127 };
128 
129 }
130 
131 #endif
class GoogleUrl
Definition: google_url.h:58
static void InitStats(StringPiece stats_prefix, Statistics *statistics)
Initializes statistics variables associated with this class.
virtual ProxyFetchPropertyCallbackCollector * InitiatePropertyCacheLookup(bool is_resource_fetch, const GoogleUrl &request_url, RewriteOptions *options, AsyncFetch *async_fetch)
Initiates the PropertyCache look up.
bool IsWellFormedUrl(const GoogleUrl &url)
Is this url_string well-formed enough to proxy through?
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
Definition: scoped_ptr.h:30
virtual void Fetch(const GoogleString &requested_url, MessageHandler *handler, AsyncFetch *async_fetch)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: proxy_interface.h:49
Definition: async_fetch.h:53
Definition: server_context.h:99
Definition: message_handler.h:39
Definition: statistics.h:298
Definition: rewrite_options.h:84
ServerContext * server_context_
Needed by subclasses when overriding InitiatePropertyCacheLookup.
Definition: proxy_interface.h:79
Definition: url_async_fetcher.h:33