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