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_REWRITER_PUBLIC_DEBUG_FILTER_H_ 00020 #define NET_INSTAWEB_REWRITER_PUBLIC_DEBUG_FILTER_H_ 00021 00022 #include "net/instaweb/htmlparse/public/empty_html_filter.h" 00023 #include "net/instaweb/util/public/basictypes.h" 00024 00025 namespace net_instaweb { 00026 00027 class RewriteDriver; 00028 class Timer; 00029 00033 class DebugFilter : public EmptyHtmlFilter { 00034 public: 00035 explicit DebugFilter(RewriteDriver* driver); 00036 virtual ~DebugFilter(); 00037 00038 virtual void EndDocument(); 00039 virtual void Flush(); 00040 00041 virtual const char* Name() const { return "Debug"; } 00042 00049 void InitParse(); 00050 void StartParse(); 00051 void EndParse(); 00052 void StartRender(); 00053 void EndRender(); 00054 00060 static GoogleString FormatFlushMessage(int64 time_since_init_parse_us, 00061 int64 parse_duration_us, 00062 int64 flush_duration_us, 00063 int64 idle_duration_us); 00064 static GoogleString FormatEndDocumentMessage(int64 time_since_init_parse_us, 00065 int64 total_parse_duration_us, 00066 int64 total_flush_duration_us, 00067 int64 total_idle_duration_us, 00068 int num_flushes); 00069 00070 private: 00073 class Event { 00074 public: 00075 Event(); 00076 inline void Clear(); 00077 inline void Start(int64 now_us); 00078 inline void End(int64 now_us); 00079 inline void AddToTotal(); 00080 00081 int64 start_us() const { return start_us_; } 00082 int64 duration_us() const { return duration_us_; } 00083 int64 total_us() const { return total_us_; } 00084 00085 private: 00086 int64 start_us_; 00087 int64 duration_us_; 00088 int64 total_us_; 00089 }; 00090 00091 void Clear(); 00092 00093 RewriteDriver* driver_; 00094 Timer* timer_; 00095 bool end_document_seen_; 00096 int num_flushes_; 00097 int64 start_doc_time_us_; 00098 Event parse_; 00099 Event render_; 00100 Event idle_; 00101 00102 DISALLOW_COPY_AND_ASSIGN(DebugFilter); 00103 }; 00104 00105 } 00106 00107 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_DEBUG_FILTER_H_