Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
flush_early_flow.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
18 
19 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_FLUSH_EARLY_FLOW_H_
20 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_FLUSH_EARLY_FLOW_H_
21 
26 
27 namespace net_instaweb {
28 
29 class AsyncFetch;
30 class FlushEarlyInfo;
31 class Histogram;
32 class MessageHandler;
33 class ProxyFetchPropertyCallbackCollector;
34 class ProxyFetchFactory;
35 class ServerContext;
36 class RewriteDriver;
37 class Statistics;
38 class TimedVariable;
39 
46  public:
47  static const char kNumRequestsFlushedEarly[];
48  static const char kNumResourcesFlushedEarly[];
49  static const char kFlushEarlyRewriteLatencyMs[];
50  static const char kNumFlushEarlyHttpStatusCodeDeemedUnstable[];
51  static const char kNumFlushEarlyRequestsRedirected[];
52  static const char kRedirectPageJs[];
53 
54  static void TryStart(
55  const GoogleString& url,
56  AsyncFetch** base_fetch,
57  RewriteDriver* driver,
58  ProxyFetchFactory* factory,
59  ProxyFetchPropertyCallbackCollector* property_callback);
60 
61  static void InitStats(Statistics* stats);
62 
63  virtual ~FlushEarlyFlow();
64 
65  private:
66  class FlushEarlyAsyncFetch;
69  void FlushEarly();
70 
72  void Cancel();
73 
74  FlushEarlyFlow(const GoogleString& url,
75  AsyncFetch* base_fetch,
76  FlushEarlyAsyncFetch* flush_early_fetch,
77  RewriteDriver* driver,
78  ProxyFetchFactory* factory,
79  ProxyFetchPropertyCallbackCollector* property_cache_callback);
80 
82  void GenerateResponseHeaders(const FlushEarlyInfo& flush_early_info);
83 
87  void FlushEarlyRewriteDone(int64 start_time_ms,
88  RewriteDriver* flush_early_driver);
89 
90  void Write(const StringPiece& val);
91 
92  GoogleString url_;
93  GoogleString dummy_head_;
94  StringWriter dummy_head_writer_;
95  int num_resources_flushed_;
96  int num_rewritten_resources_;
97  int64 average_fetch_time_;
98 
99  AsyncFetch* base_fetch_;
100  FlushEarlyAsyncFetch* flush_early_fetch_;
101  RewriteDriver* driver_;
102  ProxyFetchFactory* factory_;
103  ServerContext* server_context_;
104  ProxyFetchPropertyCallbackCollector* property_cache_callback_;
105  bool should_flush_early_lazyload_script_;
106  MessageHandler* handler_;
107  bool is_mobile_user_agent_;
108 
109  TimedVariable* num_requests_flushed_early_;
110  TimedVariable* num_resources_flushed_early_;
111  TimedVariable* num_flush_early_http_status_code_deemed_unstable_;
112  Histogram* flush_early_rewrite_latency_ms_;
113 
114  DISALLOW_COPY_AND_ASSIGN(FlushEarlyFlow);
115 };
116 
117 }
118 
119 #endif
Definition: flush_early_flow.h:45
Definition: async_fetch.h:53
Definition: rewrite_driver.h:98
Definition: server_context.h:100
Definition: proxy_fetch.h:62