Page Speed Optimization Libraries  1.11.33.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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/base/writer.h"
27 #include "pagespeed/kernel/html/html_element.h"
28 #include "pagespeed/kernel/html/html_filter.h"
29 #include "pagespeed/kernel/html/html_writer_filter.h"
30 #include "pagespeed/kernel/http/response_headers.h"
31 
32 namespace net_instaweb {
33 
34 class RewriteDriver;
35 
42 class SuppressPreheadFilter : public HtmlWriterFilter {
43  public:
44  explicit SuppressPreheadFilter(RewriteDriver* driver);
45 
46  virtual void StartDocument();
47 
48  virtual void StartElement(HtmlElement* element);
49 
50  virtual void EndElement(HtmlElement* element);
51 
52  virtual void EndDocument();
53 
54  ScriptUsage GetScriptUsage() const override { return kWillInjectScripts; }
55 
56  protected:
57  virtual void Clear();
58  RewriteDriver* driver() const { return driver_; }
59 
60  private:
61  friend class SuppressPreheadFilterTest;
62  void SendCookies(HtmlElement* element);
63 
64  void PreHeadDone(HtmlElement* element);
65 
66  static void UpdateFetchLatencyInFlushEarlyProto(int64 latency,
67  RewriteDriver*driver);
68 
70  bool ExtractAndUpdateXUACompatible(HtmlElement* element);
71 
72  bool seen_start_html_;
73  bool seen_first_head_;
74  bool has_charset_;
75  bool has_x_ua_compatible_;
76 
77  HtmlElement* noscript_element_;
78  RewriteDriver* driver_;
79  GoogleString pre_head_;
80  GoogleString charset_;
82  Writer* original_writer_;
83  StringWriter pre_head_writer_;
84  scoped_ptr<SplitWriter> pre_head_and_response_writer_;
86  scoped_ptr<ResponseHeaders> response_headers_;
87 
88 
89 };
90 
91 }
92 
93 #endif
Definition: rewrite_driver.h:98
Definition: suppress_prehead_filter.h:42