Page Speed Optimization Libraries  1.3.25.1
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 
00056  private:
00057   friend class SuppressPreheadFilterTest;
00058   void SendCookies(HtmlElement* element);
00059 
00060   static void UpdateFetchLatencyInFlushEarlyProto(int64 latency,
00061                                                   RewriteDriver*driver);
00062 
00064   bool ExtractAndUpdateXUACompatible(HtmlElement* element);
00065 
00066   bool seen_first_head_;
00067   bool has_charset_;
00068   bool has_x_ua_compatible_;
00069 
00070   HtmlElement* noscript_element_;
00071   RewriteDriver* driver_;
00072   GoogleString pre_head_; 
00073   GoogleString charset_;
00075   Writer* original_writer_;
00076   StringWriter pre_head_writer_; 
00077 
00078   scoped_ptr<SplitWriter> pre_head_and_response_writer_;
00079   ResponseHeaders response_headers_;
00080 
00081   DISALLOW_COPY_AND_ASSIGN(SuppressPreheadFilter);
00082 };
00083 
00084 }  
00085 
00086 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_SUPPRESS_PREHEAD_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines