Page Speed Optimization Libraries  1.8.31.3
net/instaweb/rewriter/public/suppress_prehead_filter.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 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  */
00017 
00018 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_SUPPRESS_PREHEAD_FILTER_H_
00019 #define NET_INSTAWEB_REWRITER_PUBLIC_SUPPRESS_PREHEAD_FILTER_H_
00020 
00021 #include "net/instaweb/htmlparse/public/html_writer_filter.h"
00022 #include "net/instaweb/http/public/response_headers.h"
00023 #include "net/instaweb/util/public/basictypes.h"
00024 #include "net/instaweb/util/public/scoped_ptr.h"
00025 #include "net/instaweb/util/public/string.h"
00026 #include "net/instaweb/util/public/string_writer.h"
00027 #include "net/instaweb/util/public/split_writer.h"
00028 
00029 namespace net_instaweb {
00030 
00031 class HtmlElement;
00032 class RewriteDriver;
00033 class Writer;
00034 
00041 class SuppressPreheadFilter : public HtmlWriterFilter {
00042  public:
00043   explicit SuppressPreheadFilter(RewriteDriver* driver);
00044 
00045   virtual void StartDocument();
00046 
00047   virtual void StartElement(HtmlElement* element);
00048 
00049   virtual void EndElement(HtmlElement* element);
00050 
00051   virtual void EndDocument();
00052 
00053  protected:
00054   virtual void Clear();
00055   RewriteDriver* driver() const { return driver_; }
00056 
00057  private:
00058   friend class SuppressPreheadFilterTest;
00059   void SendCookies(HtmlElement* element);
00060 
00061   void PreHeadDone(HtmlElement* element);
00062 
00063   static void UpdateFetchLatencyInFlushEarlyProto(int64 latency,
00064                                                   RewriteDriver*driver);
00065 
00067   bool ExtractAndUpdateXUACompatible(HtmlElement* element);
00068 
00069   bool seen_start_html_;
00070   bool seen_first_head_;
00071   bool has_charset_;
00072   bool has_x_ua_compatible_;
00073 
00074   HtmlElement* noscript_element_;
00075   RewriteDriver* driver_;
00076   GoogleString pre_head_; 
00077   GoogleString charset_;
00079   Writer* original_writer_;
00080   StringWriter pre_head_writer_; 
00081 
00082   scoped_ptr<SplitWriter> pre_head_and_response_writer_;
00083   ResponseHeaders response_headers_;
00084 
00085   DISALLOW_COPY_AND_ASSIGN(SuppressPreheadFilter);
00086 };
00087 
00088 }  
00089 
00090 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_SUPPRESS_PREHEAD_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines