Page Speed Optimization Libraries
1.2.24.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: 00049 static const char kBackgroundComputationDone[]; 00050 static const char kUpdateResponseCodeDone[]; 00051 00052 static void Start(const GoogleString& url, 00053 AsyncFetch* base_fetch, 00054 RewriteOptions* options, 00055 ProxyFetchFactory* factory, 00056 ServerContext* manager, 00057 ProxyFetchPropertyCallbackCollector* property_callback); 00058 00059 virtual ~BlinkFlowCriticalLine(); 00060 00061 static void InitStats(Statistics* statistics); 00062 00063 static const char kNumBlinkHtmlCacheHits[]; 00064 static const char kNumBlinkHtmlCacheMisses[]; 00065 static const char kNumBlinkSharedFetchesStarted[]; 00066 static const char kNumBlinkSharedFetchesCompleted[]; 00067 static const char kNumComputeBlinkCriticalLineDataCalls[]; 00068 static const char kNumBlinkHtmlMatches[]; 00069 static const char kNumBlinkHtmlMismatches[]; 00070 static const char kNumBlinkHtmlMismatchesCacheDeletes[]; 00071 static const char kNumBlinkHtmlSmartdiffMatches[]; 00072 static const char kNumBlinkHtmlSmartdiffMismatches[]; 00073 00074 private: 00075 BlinkFlowCriticalLine(const GoogleString& url, 00076 AsyncFetch* base_fetch, 00077 RewriteOptions* options, 00078 ProxyFetchFactory* factory, 00079 ServerContext* manager, 00080 ProxyFetchPropertyCallbackCollector* property_callback); 00081 00083 void SetStartRequestTimings(); 00084 00086 void SetResponseStartTime(); 00087 00091 void BlinkCriticalLineDataLookupDone( 00092 ProxyFetchPropertyCallbackCollector* collector); 00093 00096 void BlinkCriticalLineDataHit(); 00097 00100 void BlinkCriticalLineDataMiss(); 00101 00106 void TriggerProxyFetch(bool critical_line_data_found, 00107 bool serve_non_critical); 00108 00109 void WriteResponseStartAndLookUpTimings(); 00110 00114 void ServeAllPanelContents(); 00115 00119 void ServeCriticalPanelContents(); 00120 00122 void SendCriticalHtml(const GoogleString& critical_json_str); 00123 00125 void SendInlineImagesJson(const GoogleString& pushed_images_str); 00126 00128 void SendNonCriticalJson(GoogleString* non_critical_json_str); 00129 00131 void SendLazyloadImagesJs(); 00132 00133 void WriteString(const StringPiece& str); 00134 00135 int64 GetTimeElapsedFromStartRequest(); 00136 00137 GoogleString GetAddTimingScriptString(const GoogleString& timing_str, 00138 int64 time_ms); 00139 00140 void Flush(); 00141 00144 void SetFilterOptions(RewriteOptions* options) const; 00145 00147 bool IsLastResponseCodeInvalid(PropertyPage* page); 00148 00151 LogRecord* log_record(); 00152 00153 GoogleString url_; 00154 GoogleUrl google_url_; 00155 GoogleString critical_html_; 00156 AsyncFetch* base_fetch_; 00157 RewriteOptions* options_; 00158 ProxyFetchFactory* factory_; 00159 ServerContext* manager_; 00160 ProxyFetchPropertyCallbackCollector* property_callback_; 00161 scoped_ptr<BlinkCriticalLineData> blink_critical_line_data_; 00162 BlinkCriticalLineDataFinder* finder_; 00163 int64 request_start_time_ms_; 00164 int64 time_to_start_blink_flow_critical_line_ms_; 00165 int64 time_to_critical_line_data_look_up_done_ms_; 00166 00167 TimedVariable* num_blink_html_cache_hits_; 00168 TimedVariable* num_blink_shared_fetches_started_; 00169 00170 DISALLOW_COPY_AND_ASSIGN(BlinkFlowCriticalLine); 00171 }; 00172 00173 } 00174 00175 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_BLINK_FLOW_CRITICAL_LINE_H_