Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logging_html_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
40 
41 #ifndef NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_
42 #define NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_
43 
46 
47 namespace net_instaweb {
48 
49 class HtmlCdataNode;
50 class HtmlCommentNode;
51 class HtmlDirectiveNode;
52 class HtmlElement;
53 class HtmlIEDirectiveNode;
54 class StatisticsLog;
55 
58  public:
62  enum Statistic {
63  MIN_STAT = 0,
64  NUM_EXPLICIT_CLOSED = 0,
65  NUM_IMPLICIT_CLOSED,
66  NUM_BRIEF_CLOSED,
67  NUM_CLOSED,
68  NUM_UNCLOSED,
69  NUM_SPURIOUS_CLOSED,
70  NUM_TAGS,
71  NUM_CDATA,
72  NUM_COMMENTS,
73  NUM_DIRECTIVES,
74  NUM_DOCUMENTS,
75  NUM_IE_DIRECTIVES,
76  MAX_STAT
77  };
78 
79  LoggingFilter();
80 
82  virtual void StartDocument();
83  virtual void StartElement(HtmlElement* element);
84  virtual void EndElement(HtmlElement* element);
85  virtual void Cdata(HtmlCdataNode* cdata);
86  virtual void Comment(HtmlCommentNode* comment);
87  virtual void IEDirective(HtmlIEDirectiveNode* directive);
88  virtual void Directive(HtmlDirectiveNode* directive);
89  virtual const char* Name() const { return "Logging"; }
90 
92  inline int get(const Statistic statistic) const {
93  return stats_[statistic];
94  }
95 
97 
99  void LogStatistics(StatisticsLog *statistics_log) const;
100 
101  void Reset();
102 
103  private:
104  int stats_[MAX_STAT];
105 
106 
107 };
108 
109 }
110 
111 #endif
virtual void StartDocument()
HtmlFilter methods.
Definition: empty_html_filter.h:37
Definition: html_element.h:42
virtual void Directive(HtmlDirectiveNode *directive)
Called for HTML directives (e.g. <!doctype foobar>).
Leaf node representing an HTML comment.
Definition: html_node.h:193
Statistic
Definition: logging_html_filter.h:62
Definition: statistics_log.h:26
virtual void IEDirective(HtmlIEDirectiveNode *directive)
void LogStatistics(StatisticsLog *statistics_log) const
Logging, diffing, and aggregation.
virtual void Comment(HtmlCommentNode *comment)
Called for HTML comments that aren't IE directives (e.g. ).
Leaf node representing an HTML directive.
Definition: html_node.h:233
Leaf node representing a CDATA section.
Definition: html_node.h:147
Counts some basic statistics observed as HTML is parsed.
Definition: logging_html_filter.h:57
Leaf node representing an HTML IE directive.
Definition: html_node.h:213
virtual const char * Name() const
The name of this filter – used for logging and debugging.
Definition: logging_html_filter.h:89
virtual void StartElement(HtmlElement *element)
virtual void Cdata(HtmlCdataNode *cdata)
Called for CDATA blocks (e.g. <![CDATA[foobar]]>)