Page Speed Optimization Libraries  1.8.31.2
net/instaweb/htmlparse/public/logging_html_filter.h
Go to the documentation of this file.
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 
00040 
00041 #ifndef NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_
00042 #define NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_
00043 
00044 #include "net/instaweb/htmlparse/public/empty_html_filter.h"
00045 #include "pagespeed/kernel/base/basictypes.h"
00046 
00047 namespace net_instaweb {
00048 
00049 class HtmlCdataNode;
00050 class HtmlCommentNode;
00051 class HtmlDirectiveNode;
00052 class HtmlElement;
00053 class HtmlIEDirectiveNode;
00054 class StatisticsLog;
00055 
00057 class LoggingFilter : public EmptyHtmlFilter {
00058  public:
00062   enum Statistic {
00063     MIN_STAT = 0,
00064     NUM_EXPLICIT_CLOSED = 0,
00065     NUM_IMPLICIT_CLOSED,
00066     NUM_BRIEF_CLOSED,
00067     NUM_CLOSED,
00068     NUM_UNCLOSED,
00069     NUM_SPURIOUS_CLOSED,
00070     NUM_TAGS,
00071     NUM_CDATA,
00072     NUM_COMMENTS,
00073     NUM_DIRECTIVES,
00074     NUM_DOCUMENTS,
00075     NUM_IE_DIRECTIVES,
00076     MAX_STAT
00077   };
00078 
00079   LoggingFilter();
00080 
00082   virtual void StartDocument();
00083   virtual void StartElement(HtmlElement* element);
00084   virtual void EndElement(HtmlElement* element);
00085   virtual void Cdata(HtmlCdataNode* cdata);
00086   virtual void Comment(HtmlCommentNode* comment);
00087   virtual void IEDirective(HtmlIEDirectiveNode* directive);
00088   virtual void Directive(HtmlDirectiveNode* directive);
00089   virtual const char* Name() const { return "Logging"; }
00090 
00092   inline int get(const Statistic statistic) const {
00093     return stats_[statistic];
00094   }
00095 
00097 
00099   void LogStatistics(StatisticsLog *statistics_log) const;
00100 
00101   void Reset();
00102 
00103  private:
00104   int stats_[MAX_STAT];
00105 
00106   DISALLOW_COPY_AND_ASSIGN(LoggingFilter);
00107 };
00108 
00109 }  
00110 
00111 #endif  ///< NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines