Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cache_html_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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  */
16 
19 
20 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CACHE_HTML_FILTER_H_
21 #define NET_INSTAWEB_REWRITER_PUBLIC_CACHE_HTML_FILTER_H_
22 
23 #include <vector>
24 
25 #include "net/instaweb/rewriter/cache_html_info.pb.h"
27 #include "net/instaweb/util/public/property_cache.h"
28 #include "pagespeed/kernel/base/basictypes.h"
29 #include "pagespeed/kernel/base/json.h"
30 #include "pagespeed/kernel/base/string.h"
31 #include "pagespeed/kernel/base/string_util.h"
32 #include "pagespeed/kernel/base/string_writer.h"
33 #include "pagespeed/kernel/html/html_writer_filter.h"
34 
35 namespace net_instaweb {
36 
37 class HtmlElement;
38 class RewriteDriver;
39 class RewriteOptions;
40 
43 class CacheHtmlFilter : public HtmlWriterFilter {
44  public:
45  explicit CacheHtmlFilter(RewriteDriver* rewrite_driver);
46  virtual ~CacheHtmlFilter();
47 
48  virtual void StartDocument();
49  virtual void StartElement(HtmlElement* element);
50  virtual void EndElement(HtmlElement* element);
51  virtual void EndDocument();
52  void WriteString(StringPiece str);
53  virtual void Flush();
54  virtual const char* Name() const { return "CacheHtmlFilter"; }
55 
56  private:
57  void SendCookies();
58  void SendNonCacheableObject(const Json::Value& json);
62  GoogleString GetXpathOfCurrentElement(HtmlElement* element);
63 
64  RewriteDriver* rewrite_driver_;
65  const RewriteOptions* rewrite_options_;
66  AttributesToNonCacheableValuesMap attribute_non_cacheable_values_map_;
67  std::vector<int> panel_number_num_instances_;
68  GoogleString buffer_;
69  StringWriter string_writer_;
70  const HtmlElement* current_non_cacheable_element_;
71  GoogleString current_panel_id_;
72  const PropertyCache::Cohort* cohort_;
73  CacheHtmlInfo cache_html_info_;
74  bool abort_filter_;
75  std::vector<int> num_children_stack_;
76 
77  DISALLOW_COPY_AND_ASSIGN(CacheHtmlFilter);
78 };
79 
80 }
81 
82 #endif
Definition: rewrite_driver.h:98
Definition: rewrite_options.h:83
Definition: cache_html_filter.h:43