Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
suppress_prehead_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
17 
18 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_SUPPRESS_PREHEAD_FILTER_H_
19 #define NET_INSTAWEB_REWRITER_PUBLIC_SUPPRESS_PREHEAD_FILTER_H_
20 
21 #include "pagespeed/kernel/base/basictypes.h"
22 #include "pagespeed/kernel/base/scoped_ptr.h"
23 #include "pagespeed/kernel/base/split_writer.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/base/string_writer.h"
26 #include "pagespeed/kernel/html/html_writer_filter.h"
27 #include "pagespeed/kernel/http/response_headers.h"
28 
29 namespace net_instaweb {
30 
31 class HtmlElement;
32 class RewriteDriver;
33 class Writer;
34 
41 class SuppressPreheadFilter : public HtmlWriterFilter {
42  public:
43  explicit SuppressPreheadFilter(RewriteDriver* driver);
44 
45  virtual void StartDocument();
46 
47  virtual void StartElement(HtmlElement* element);
48 
49  virtual void EndElement(HtmlElement* element);
50 
51  virtual void EndDocument();
52 
53  protected:
54  virtual void Clear();
55  RewriteDriver* driver() const { return driver_; }
56 
57  private:
58  friend class SuppressPreheadFilterTest;
59  void SendCookies(HtmlElement* element);
60 
61  void PreHeadDone(HtmlElement* element);
62 
63  static void UpdateFetchLatencyInFlushEarlyProto(int64 latency,
64  RewriteDriver*driver);
65 
67  bool ExtractAndUpdateXUACompatible(HtmlElement* element);
68 
69  bool seen_start_html_;
70  bool seen_first_head_;
71  bool has_charset_;
72  bool has_x_ua_compatible_;
73 
74  HtmlElement* noscript_element_;
75  RewriteDriver* driver_;
76  GoogleString pre_head_;
77  GoogleString charset_;
79  Writer* original_writer_;
80  StringWriter pre_head_writer_;
81  scoped_ptr<SplitWriter> pre_head_and_response_writer_;
83  scoped_ptr<ResponseHeaders> response_headers_;
84 
85  DISALLOW_COPY_AND_ASSIGN(SuppressPreheadFilter);
86 };
87 
88 }
89 
90 #endif
Definition: rewrite_driver.h:98
Definition: suppress_prehead_filter.h:41