Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cache_extender.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 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 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CACHE_EXTENDER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_CACHE_EXTENDER_H_
21 
30 
31 namespace net_instaweb {
32 
33 class CachedResult;
34 class HtmlElement;
35 class ResponseHeaders;
36 class RewriteContext;
37 class RewriteDriver;
38 class Statistics;
39 class Variable;
40 
49 class CacheExtender : public RewriteFilter {
50  public:
51  static const char kCacheExtensions[];
52  static const char kNotCacheable[];
53 
54  explicit CacheExtender(RewriteDriver* driver);
55  virtual ~CacheExtender();
56 
57  static void InitStats(Statistics* statistics);
58 
59  virtual void StartDocumentImpl() {}
60  virtual void StartElementImpl(HtmlElement* element);
61  virtual void EndElementImpl(HtmlElement* element) {}
62 
63  virtual const char* Name() const { return "CacheExtender"; }
64  virtual const char* id() const { return RewriteOptions::kCacheExtenderId; }
65 
68  RewriteContext* MakeNestedContext(RewriteContext* parent,
69  const ResourceSlotPtr& slot);
70 
71  protected:
72  virtual bool ComputeOnTheFly() const;
73  virtual RewriteContext* MakeRewriteContext();
74 
75  private:
76  class Context;
77  friend class Context;
78 
79  RewriteResult RewriteLoadedResource(const ResourcePtr& input_resource,
80  const OutputResourcePtr& output_resource,
81  CachedResult* result);
82 
83  bool ShouldRewriteResource(
84  const ResponseHeaders* headers, int64 now_ms,
85  const ResourcePtr& input_resource, const StringPiece& url,
86  CachedResult* result) const;
87 
88  Variable* extension_count_;
89  Variable* not_cacheable_count_;
90 
91 
92 };
93 
94 }
95 
96 #endif
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
RewriteContext * MakeNestedContext(RewriteContext *parent, const ResourceSlotPtr &slot)
virtual void StartDocumentImpl()
Definition: cache_extender.h:59
Definition: html_element.h:42
virtual const char * Name() const
The name of this filter – used for logging and debugging.
Definition: cache_extender.h:63
Definition: rewrite_filter.h:35
Definition: rewrite_driver.h:100
RewriteResult
Definition: rewrite_result.h:27
virtual RewriteContext * MakeRewriteContext()
virtual bool ComputeOnTheFly() const
Definition: cache_extender.h:49