~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/rewriter/public/file_load_mapping.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 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
 
 */
16
 
 
17
 
// Author: jefftk@google.com (Jeff Kaufman)
18
 
 
19
 
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_
20
 
#define NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_
21
 
 
22
 
#include "net/instaweb/util/public/basictypes.h"
23
 
#include "net/instaweb/util/public/manually_ref_counted.h"
24
 
#include "net/instaweb/util/public/re2.h"
25
 
#include "net/instaweb/util/public/string.h"
26
 
#include "net/instaweb/util/public/string_util.h"
27
 
 
28
 
namespace net_instaweb {
29
 
 
30
 
// Class for storing a mapping from a URL to a filesystem path, for use by
31
 
// FileLoadPolicy.
32
 
class FileLoadMapping : public ManuallyRefCounted {
33
 
 public:
34
 
  virtual ~FileLoadMapping();
35
 
 
36
 
  // If this mapping applies to this url, put the mapped path into filename and
37
 
  // return true.  Otherwise return false.
38
 
  virtual bool Substitute(const StringPiece& url,
39
 
                          GoogleString* filename) const = 0;
40
 
};
41
 
 
42
 
class FileLoadMappingRegexp : public FileLoadMapping {
43
 
 public:
44
 
  FileLoadMappingRegexp(const GoogleString& url_regexp,
45
 
                        const GoogleString& filename_prefix)
46
 
      : url_regexp_(url_regexp),
47
 
        url_regexp_str_(url_regexp),
48
 
        filename_prefix_(filename_prefix) {}
49
 
 
50
 
  virtual bool Substitute(const StringPiece& url, GoogleString* filename) const;
51
 
 
52
 
 private:
53
 
  const RE2 url_regexp_;
54
 
  // RE2s can't be copied, so we need to keep the string around.
55
 
  const GoogleString url_regexp_str_;
56
 
  const GoogleString filename_prefix_;
57
 
 
58
 
  DISALLOW_COPY_AND_ASSIGN(FileLoadMappingRegexp);
59
 
};
60
 
 
61
 
class FileLoadMappingLiteral : public FileLoadMapping {
62
 
 public:
63
 
  FileLoadMappingLiteral(const GoogleString& url_prefix,
64
 
                         const GoogleString& filename_prefix)
65
 
      : url_prefix_(url_prefix),
66
 
        filename_prefix_(filename_prefix) {}
67
 
 
68
 
  virtual bool Substitute(const StringPiece& url, GoogleString* filename) const;
69
 
 
70
 
 private:
71
 
  const GoogleString url_prefix_;
72
 
  const GoogleString filename_prefix_;
73
 
 
74
 
  DISALLOW_COPY_AND_ASSIGN(FileLoadMappingLiteral);
75
 
};
76
 
 
77
 
}  // namespace net_instaweb
78
 
 
79
 
#endif  // NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_