Page Speed Optimization Libraries  1.2.24.1
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/util/public/basictypes.h"
00045 #include "net/instaweb/htmlparse/public/empty_html_filter.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 
00056 class LoggingFilter : public EmptyHtmlFilter {
00057  public:
00061   enum Statistic {
00062     MIN_STAT = 0,
00063     NUM_EXPLICIT_CLOSED = 0,
00064     NUM_IMPLICIT_CLOSED,
00065     NUM_BRIEF_CLOSED,
00066     NUM_CLOSED,
00067     NUM_UNCLOSED,
00068     NUM_SPURIOUS_CLOSED,
00069     NUM_TAGS,
00070     NUM_CDATA,
00071     NUM_COMMENTS,
00072     NUM_DIRECTIVES,
00073     NUM_DOCUMENTS,
00074     NUM_IE_DIRECTIVES,
00075     MAX_STAT
00076   };
00077 
00078   LoggingFilter();
00079 
00081   virtual void StartDocument();
00082   virtual void StartElement(HtmlElement* element);
00083   virtual void EndElement(HtmlElement* element);
00084   virtual void Cdata(HtmlCdataNode* cdata);
00085   virtual void Comment(HtmlCommentNode* comment);
00086   virtual void IEDirective(HtmlIEDirectiveNode* directive);
00087   virtual void Directive(HtmlDirectiveNode* directive);
00088   virtual const char* Name() const { return "Logging"; }
00089 
00091   inline int get(const Statistic statistic) const {
00092     return stats_[statistic];
00093   }
00094 
00096 
00098   void LogStatistics(StatisticsLog *statistics_log) const;
00099 
00100   void Reset();
00101 
00102  private:
00103   int stats_[MAX_STAT];
00104 
00105   DISALLOW_COPY_AND_ASSIGN(LoggingFilter);
00106 };
00107 
00108 }  
00109 
00110 #endif  ///< NET_INSTAWEB_HTMLPARSE_PUBLIC_LOGGING_HTML_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines