Page Speed Optimization Libraries
1.4.26.1
|
00001 /* 00002 * Copyright 2010 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 00042 00043 #ifndef NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_ 00044 #define NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_ 00045 00046 #include "net/instaweb/util/public/basictypes.h" 00047 #include "net/instaweb/htmlparse/public/empty_html_filter.h" 00048 00049 namespace net_instaweb { 00050 00051 class HtmlCdataNode; 00052 class HtmlCommentNode; 00053 class HtmlDirectiveNode; 00054 class HtmlElement; 00055 class HtmlIEDirectiveNode; 00056 class StatisticsLog; 00057 00058 class LoggingFilter : public EmptyHtmlFilter { 00059 public: 00063 enum Statistic { 00064 MIN_STAT = 0, 00065 NUM_EXPLICIT_CLOSED = 0, 00066 NUM_IMPLICIT_CLOSED, 00067 NUM_BRIEF_CLOSED, 00068 NUM_CLOSED, 00069 NUM_UNCLOSED, 00070 NUM_SPURIOUS_CLOSED, 00071 NUM_TAGS, 00072 NUM_CDATA, 00073 NUM_COMMENTS, 00074 NUM_DIRECTIVES, 00075 NUM_DOCUMENTS, 00076 NUM_IE_DIRECTIVES, 00077 NUM_IMG_TAGS, 00078 NUM_INLINED_IMG_TAGS, 00079 MAX_STAT 00080 }; 00081 00082 LoggingFilter(); 00083 00085 virtual void StartDocument(); 00086 virtual void StartElement(HtmlElement* element); 00087 virtual void EndElement(HtmlElement* element); 00088 virtual void Cdata(HtmlCdataNode* cdata); 00089 virtual void Comment(HtmlCommentNode* comment); 00090 virtual void IEDirective(HtmlIEDirectiveNode* directive); 00091 virtual void Directive(HtmlDirectiveNode* directive); 00092 virtual const char* Name() const { return "Logging"; } 00093 00095 inline int get(const Statistic statistic) const { 00096 return stats_[statistic]; 00097 } 00098 00100 00102 void LogStatistics(StatisticsLog *statistics_log) const; 00103 00104 int num_img_tags() const { return stats_[NUM_IMG_TAGS]; } 00105 int num_inlined_img_tags() const { return stats_[NUM_INLINED_IMG_TAGS]; } 00106 00107 void Reset(); 00108 00109 private: 00110 int stats_[MAX_STAT]; 00111 00112 DISALLOW_COPY_AND_ASSIGN(LoggingFilter); 00113 }; 00114 00115 } 00116 00117 #endif ///< NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_