~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/rewriter/public/cache_extender.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
17
 
// Author: jmarantz@google.com (Joshua Marantz)
18
 
 
19
 
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_CACHE_EXTENDER_H_
20
 
#define NET_INSTAWEB_REWRITER_PUBLIC_CACHE_EXTENDER_H_
21
 
 
22
 
#include "net/instaweb/rewriter/public/resource.h"  // for ResourcePtr
23
 
#include "net/instaweb/rewriter/public/server_context.h"
24
 
#include "net/instaweb/rewriter/public/resource_slot.h"
25
 
#include "net/instaweb/rewriter/public/rewrite_filter.h"
26
 
#include "net/instaweb/rewriter/public/rewrite_options.h"
27
 
#include "net/instaweb/rewriter/public/rewrite_result.h"
28
 
#include "net/instaweb/util/public/basictypes.h"
29
 
#include "net/instaweb/util/public/string_util.h"
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
 
 
41
 
// Rewrites resources without changing their content -- just their
42
 
// URLs and headers.  The original intent of this filter was limited
43
 
// to cache extension.  However, its scope has been expanded to include
44
 
// domain sharding and moving static resources to cookieless domains or
45
 
// CDNs.
46
 
//
47
 
// TODO(jmarantz): rename this class to something more generic, like
48
 
// RenameUrlFilter or ProxyUrlFilter.
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
 
 
66
 
  // Creates a nested rewrite for given parent and slot, and returns it.
67
 
  // The result is not registered with the parent.
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
 
  DISALLOW_COPY_AND_ASSIGN(CacheExtender);
92
 
};
93
 
 
94
 
}  // namespace net_instaweb
95
 
 
96
 
#endif  // NET_INSTAWEB_REWRITER_PUBLIC_CACHE_EXTENDER_H_