Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_url_namer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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_TEST_URL_NAMER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_TEST_URL_NAMER_H_
21 
23 
27 
28 namespace net_instaweb {
29 
30 class GoogleUrl;
31 class OutputResource;
32 class ResourceNamer;
33 class RewriteOptions;
34 
37 class TestUrlNamer : public UrlNamer {
38  public:
39  TestUrlNamer();
40  virtual ~TestUrlNamer();
41 
42  virtual GoogleString Encode(const RewriteOptions* rewrite_options,
43  const OutputResource& output_resource,
44  EncodeOption encode_option) const;
45 
46  virtual bool Decode(const GoogleUrl& request_url,
47  const RewriteOptions* rewrite_options,
48  GoogleUrl* owner_domain,
49  GoogleString* decoded) const;
50 
51  static GoogleString EncodeUrl(const StringPiece& original_base,
52  const StringPiece& unmapped_base,
53  const StringPiece& resolved_path,
54  const ResourceNamer& leaf_details);
55 
58  virtual bool ProxyMode() const { return proxy_mode_; }
59 
61  virtual bool IsProxyEncoded(const GoogleUrl& url) const;
62 
64  static void SetProxyMode(bool value) { proxy_mode_ = value; }
65 
68  static void UseNormalEncoding(bool yes) {
69  use_normal_encoding_ = yes;
70  }
71 
72  static bool UseNormalEncoding() { return use_normal_encoding_; }
73 
74  private:
75  bool IsOriginEncoded(const GoogleUrl& url) const;
76  bool IsPathEncoded(const GoogleUrl& url) const;
77 
78  static bool use_normal_encoding_;
79  static bool proxy_mode_;
80 
81  DISALLOW_COPY_AND_ASSIGN(TestUrlNamer);
82 };
83 
84 }
85 
86 #endif
Definition: url_namer.h:37
virtual bool ProxyMode() const
Definition: test_url_namer.h:58
virtual GoogleString Encode(const RewriteOptions *rewrite_options, const OutputResource &output_resource, EncodeOption encode_option) const
static void SetProxyMode(bool value)
Set whether a test needs the URL namer to act in proxy mode.
Definition: test_url_namer.h:64
virtual bool Decode(const GoogleUrl &request_url, const RewriteOptions *rewrite_options, GoogleUrl *owner_domain, GoogleString *decoded) const
Definition: test_url_namer.h:37
virtual bool IsProxyEncoded(const GoogleUrl &url) const
Determines whether the specified URL has been mapped to our proxy domain.
Definition: output_resource.h:44
static void UseNormalEncoding(bool yes)
Definition: test_url_namer.h:68
Definition: rewrite_options.h:81
Definition: resource_namer.h:32