Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
domain_rewrite_filter.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_DOMAIN_REWRITE_FILTER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_DOMAIN_REWRITE_FILTER_H_
21 
23 #include "pagespeed/kernel/base/basictypes.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/base/string_util.h"
26 
27 namespace net_instaweb {
28 
29 class HtmlElement;
30 class GoogleUrl;
31 class ResponseHeaders;
32 class RewriteDriver;
33 class Statistics;
34 class Variable;
35 
41  public:
42  DomainRewriteFilter(RewriteDriver* rewrite_driver, Statistics* stats);
44  static void InitStats(Statistics* statistics);
45  virtual void StartDocumentImpl();
46  virtual void EndDocument();
47  virtual void StartElementImpl(HtmlElement* element);
48  virtual void EndElementImpl(HtmlElement* element) {}
49 
50  virtual const char* Name() const { return "DomainRewrite"; }
51 
52  enum RewriteResult {
53  kRewroteDomain,
54  kDomainUnchanged,
55  kFail,
56  };
57 
63  RewriteResult Rewrite(const StringPiece& input_url,
64  const GoogleUrl& base_url,
65  const RewriteDriver* driver,
66  bool apply_sharding,
67  GoogleString* output_url) const;
68 
71  void UpdateLocationHeader(const GoogleUrl& base_url, RewriteDriver* driver,
72  ResponseHeaders* headers) const;
73 
74  private:
76  Variable* rewrite_count_;
77 
78  DISALLOW_COPY_AND_ASSIGN(DomainRewriteFilter);
79 };
80 
81 }
82 
83 #endif
Definition: common_filter.h:48
void UpdateLocationHeader(const GoogleUrl &base_url, RewriteDriver *driver, ResponseHeaders *headers) const
Definition: rewrite_driver.h:98
const GoogleUrl & base_url() const
Getters.
Definition: domain_rewrite_filter.h:40
RewriteResult Rewrite(const StringPiece &input_url, const GoogleUrl &base_url, const RewriteDriver *driver, bool apply_sharding, GoogleString *output_url) const