Page Speed Optimization Libraries  1.2.24.1
net/instaweb/rewriter/public/url_namer.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http:///www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00018 
00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_URL_NAMER_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_URL_NAMER_H_
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/string.h"
00024 
00025 namespace net_instaweb {
00026 
00027 class Function;
00028 class GoogleUrl;
00029 class OutputResource;
00030 class MessageHandler;
00031 class RequestHeaders;
00032 class RewriteOptions;
00033 
00039 class UrlNamer {
00040  public:
00041   enum EncodeOption {
00042     kSharded,
00043     kUnsharded
00044   };
00045 
00046   class Callback {
00047    public:
00048     Callback() {}
00049     virtual ~Callback();
00053     virtual void Done(RewriteOptions* rewrite_options) = 0;
00054 
00055    private:
00056     DISALLOW_COPY_AND_ASSIGN(Callback);
00057   };
00058   UrlNamer();
00059   virtual ~UrlNamer();
00060 
00068   virtual GoogleString Encode(const RewriteOptions* rewrite_options,
00069                               const OutputResource& output_resource,
00070                               EncodeOption encode_option) const;
00071 
00079   virtual bool Decode(const GoogleUrl& request_url,
00080                       GoogleUrl* owner_domain,
00081                       GoogleString* decoded) const;
00082 
00087   virtual bool IsAuthorized(const GoogleUrl& request_url,
00088                             const RewriteOptions& options) const;
00089 
00091   virtual void DecodeOptions(const GoogleUrl& request_url,
00092                              const RequestHeaders& request_headers,
00093                              Callback* callback,
00094                              MessageHandler* handler) const;
00095 
00097   virtual void PrepareRequest(const RewriteOptions* rewrite_options,
00098                               GoogleString* url,
00099                               RequestHeaders* request_headers,
00100                               bool* success,
00101                               Function* func, MessageHandler* handler);
00102 
00104   virtual void ConfigureCustomOptions(const RequestHeaders& request_headers,
00105                                       RewriteOptions* options) const {}
00106 
00109   virtual bool ProxyMode() const { return false; }
00110 
00113   virtual bool IsProxyEncoded(const GoogleUrl& url) const { return false; }
00114 
00115   const GoogleString& get_proxy_domain() {
00116     return proxy_domain_;
00117   }
00118 
00119   void set_proxy_domain(const GoogleString proxy_domain) {
00120     proxy_domain_ = proxy_domain;
00121   }
00122 
00123  private:
00124   GoogleString proxy_domain_;
00125 
00126   DISALLOW_COPY_AND_ASSIGN(UrlNamer);
00127 };
00128 
00129 }  
00130 
00131 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_URL_NAMER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines