Page Speed Optimization Libraries  1.6.29.3
net/instaweb/automatic/public/html_detector.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 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 
00022 
00023 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_HTML_DETECTOR_H_
00024 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_HTML_DETECTOR_H_
00025 
00026 #include "base/logging.h"
00027 #include "net/instaweb/util/public/basictypes.h"
00028 #include "net/instaweb/util/public/string.h"
00029 #include "net/instaweb/util/public/string_util.h"
00030 
00031 namespace net_instaweb {
00032 
00054 class HtmlDetector {
00055  public:
00056   HtmlDetector();
00057   ~HtmlDetector();
00058 
00068   bool ConsiderInput(const StringPiece& data);
00069 
00072   bool already_decided() const { return already_decided_; }
00073 
00075   bool probable_html() const {
00076     DCHECK(already_decided_);
00077     return probable_html_;
00078   }
00079 
00083   void ReleaseBuffered(GoogleString* out_buffer);
00084 
00088   void ForceDecision(bool is_html);
00089 
00090  private:
00091   GoogleString buffer_;
00092   bool already_decided_;
00093   bool probable_html_; 
00094 
00095   DISALLOW_COPY_AND_ASSIGN(HtmlDetector);
00096 };
00097 
00098 }  
00099 
00100 #endif  ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_HTML_DETECTOR_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines