Page Speed Optimization Libraries
1.4.26.1
|
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_BLINK_FLOW_CRITICAL_LINE_H_ 00020 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_BLINK_FLOW_CRITICAL_LINE_H_ 00021 00022 #include "net/instaweb/util/public/basictypes.h" 00023 #include "net/instaweb/util/public/google_url.h" 00024 #include "net/instaweb/util/public/scoped_ptr.h" 00025 #include "net/instaweb/util/public/string.h" 00026 #include "net/instaweb/util/public/string_util.h" 00027 00028 namespace net_instaweb { 00029 00030 class AsyncFetch; 00031 class BlinkCriticalLineData; 00032 class BlinkCriticalLineDataFinder; 00033 class LogRecord; 00034 class PropertyPage; 00035 class ProxyFetchPropertyCallbackCollector; 00036 class ProxyFetchFactory; 00037 class ServerContext; 00038 class RewriteOptions; 00039 class Statistics; 00040 class TimedVariable; 00041 00045 class BlinkFlowCriticalLine { 00046 public: 00047 class LogHelper; 00048 00051 static const char kBackgroundComputationDone[]; 00052 static const char kUpdateResponseCodeDone[]; 00053 00054 static void Start(const GoogleString& url, 00055 AsyncFetch* base_fetch, 00056 RewriteOptions* options, 00057 ProxyFetchFactory* factory, 00058 ServerContext* manager, 00059 ProxyFetchPropertyCallbackCollector* property_callback); 00060 00061 virtual ~BlinkFlowCriticalLine(); 00062 00063 static void InitStats(Statistics* statistics); 00064 00065 static const char kNumBlinkHtmlCacheHits[]; 00066 static const char kNumBlinkHtmlCacheMisses[]; 00067 static const char kNumBlinkSharedFetchesStarted[]; 00068 static const char kNumBlinkSharedFetchesCompleted[]; 00069 static const char kNumComputeBlinkCriticalLineDataCalls[]; 00070 static const char kNumBlinkHtmlMatches[]; 00071 static const char kNumBlinkHtmlMismatches[]; 00072 static const char kNumBlinkHtmlMismatchesCacheDeletes[]; 00073 static const char kNumBlinkHtmlSmartdiffMatches[]; 00074 static const char kNumBlinkHtmlSmartdiffMismatches[]; 00075 00076 private: 00077 BlinkFlowCriticalLine(const GoogleString& url, 00078 AsyncFetch* base_fetch, 00079 RewriteOptions* options, 00080 ProxyFetchFactory* factory, 00081 ServerContext* manager, 00082 ProxyFetchPropertyCallbackCollector* property_callback); 00083 00085 void SetStartRequestTimings(); 00086 00088 void SetResponseStartTime(); 00089 00093 void BlinkCriticalLineDataLookupDone( 00094 ProxyFetchPropertyCallbackCollector* collector); 00095 00098 void BlinkCriticalLineDataHit(); 00099 00102 void BlinkCriticalLineDataMiss(); 00103 00108 void TriggerProxyFetch(bool critical_line_data_found, 00109 bool serve_non_critical); 00110 00111 void WriteResponseStartAndLookUpTimings(); 00112 00116 void ServeAllPanelContents(); 00117 00121 void ServeCriticalPanelContents(); 00122 00124 void SendCriticalHtml(const GoogleString& critical_json_str); 00125 00127 void SendInlineImagesJson(const GoogleString& pushed_images_str); 00128 00130 void SendNonCriticalJson(GoogleString* non_critical_json_str); 00131 00133 void SendLazyloadImagesJs(); 00134 00135 void WriteString(const StringPiece& str); 00136 00137 int64 GetTimeElapsedFromStartRequest(); 00138 00139 GoogleString GetAddTimingScriptString(const GoogleString& timing_str, 00140 int64 time_ms); 00141 00142 void Flush(); 00143 00146 void SetFilterOptions(RewriteOptions* options) const; 00147 00149 bool IsLastResponseCodeInvalid(PropertyPage* page); 00150 00151 GoogleString url_; 00152 GoogleUrl google_url_; 00153 GoogleString critical_html_; 00154 AsyncFetch* base_fetch_; 00157 scoped_ptr<LogRecord> blink_log_record_; 00158 RewriteOptions* options_; 00159 ProxyFetchFactory* factory_; 00160 ServerContext* manager_; 00161 ProxyFetchPropertyCallbackCollector* property_callback_; 00162 scoped_ptr<BlinkCriticalLineData> blink_critical_line_data_; 00163 BlinkCriticalLineDataFinder* finder_; 00164 int64 request_start_time_ms_; 00165 int64 time_to_start_blink_flow_critical_line_ms_; 00166 int64 time_to_critical_line_data_look_up_done_ms_; 00167 scoped_ptr<LogHelper> blink_log_helper_; 00168 00169 TimedVariable* num_blink_html_cache_hits_; 00170 TimedVariable* num_blink_shared_fetches_started_; 00171 00172 DISALLOW_COPY_AND_ASSIGN(BlinkFlowCriticalLine); 00173 }; 00174 00175 } 00176 00177 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_BLINK_FLOW_CRITICAL_LINE_H_