Page Speed Optimization Libraries
1.7.30.3
|
00001 /* 00002 * Copyright 2012 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 00018 00019 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_FLUSH_EARLY_FLOW_H_ 00020 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_FLUSH_EARLY_FLOW_H_ 00021 00022 #include "net/instaweb/util/public/basictypes.h" 00023 #include "net/instaweb/util/public/string.h" 00024 #include "net/instaweb/util/public/string_util.h" 00025 #include "net/instaweb/util/public/string_writer.h" 00026 00027 namespace net_instaweb { 00028 00029 class AsyncFetch; 00030 class FlushEarlyInfo; 00031 class Histogram; 00032 class MessageHandler; 00033 class ProxyFetchPropertyCallbackCollector; 00034 class ProxyFetchFactory; 00035 class ServerContext; 00036 class RewriteDriver; 00037 class Statistics; 00038 class TimedVariable; 00039 00045 class FlushEarlyFlow { 00046 public: 00047 static const char kNumRequestsFlushedEarly[]; 00048 static const char kNumResourcesFlushedEarly[]; 00049 static const char kFlushEarlyRewriteLatencyMs[]; 00050 static const char kNumFlushEarlyHttpStatusCodeDeemedUnstable[]; 00051 static const char kNumFlushEarlyRequestsRedirected[]; 00052 static const char kRedirectPageJs[]; 00053 00054 static void TryStart( 00055 const GoogleString& url, 00056 AsyncFetch** base_fetch, 00057 RewriteDriver* driver, 00058 ProxyFetchFactory* factory, 00059 ProxyFetchPropertyCallbackCollector* property_callback); 00060 00061 static void InitStats(Statistics* stats); 00062 00063 virtual ~FlushEarlyFlow(); 00064 00065 private: 00066 class FlushEarlyAsyncFetch; 00069 void FlushEarly(); 00070 00072 void Cancel(); 00073 00074 FlushEarlyFlow(const GoogleString& url, 00075 AsyncFetch* base_fetch, 00076 FlushEarlyAsyncFetch* flush_early_fetch, 00077 RewriteDriver* driver, 00078 ProxyFetchFactory* factory, 00079 ProxyFetchPropertyCallbackCollector* property_cache_callback); 00080 00082 void GenerateResponseHeaders(const FlushEarlyInfo& flush_early_info); 00083 00087 void FlushEarlyRewriteDone(int64 start_time_ms, 00088 RewriteDriver* flush_early_driver); 00089 00090 void Write(const StringPiece& val); 00091 00092 GoogleString url_; 00093 GoogleString dummy_head_; 00094 StringWriter dummy_head_writer_; 00095 int num_resources_flushed_; 00096 int num_rewritten_resources_; 00097 int64 average_fetch_time_; 00098 00099 AsyncFetch* base_fetch_; 00100 FlushEarlyAsyncFetch* flush_early_fetch_; 00101 RewriteDriver* driver_; 00102 ProxyFetchFactory* factory_; 00103 ServerContext* server_context_; 00104 ProxyFetchPropertyCallbackCollector* property_cache_callback_; 00105 bool should_flush_early_lazyload_script_; 00106 MessageHandler* handler_; 00107 bool is_mobile_user_agent_; 00108 00109 TimedVariable* num_requests_flushed_early_; 00110 TimedVariable* num_resources_flushed_early_; 00111 TimedVariable* num_flush_early_http_status_code_deemed_unstable_; 00112 Histogram* flush_early_rewrite_latency_ms_; 00113 00114 DISALLOW_COPY_AND_ASSIGN(FlushEarlyFlow); 00115 }; 00116 00117 } 00118 00119 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_FLUSH_EARLY_FLOW_H_