Page Speed Optimization Libraries  1.5.27.2
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 #include "pagespeed/kernel/base/callback.h"
00025 
00026 namespace net_instaweb {
00027 
00028 class Function;
00029 class GoogleUrl;
00030 class OutputResource;
00031 class MessageHandler;
00032 class RequestHeaders;
00033 class RewriteOptions;
00034 
00040 class UrlNamer {
00041  public:
00042   enum EncodeOption {
00043     kSharded,
00044     kUnsharded
00045   };
00046 
00047   typedef Callback1<RewriteOptions*> Callback;
00048   UrlNamer();
00049   virtual ~UrlNamer();
00050 
00058   virtual GoogleString Encode(const RewriteOptions* rewrite_options,
00059                               const OutputResource& output_resource,
00060                               EncodeOption encode_option) const;
00061 
00069   virtual bool Decode(const GoogleUrl& request_url,
00070                       GoogleUrl* owner_domain,
00071                       GoogleString* decoded) const;
00072 
00077   virtual bool IsAuthorized(const GoogleUrl& request_url,
00078                             const RewriteOptions& options) const;
00079 
00081   virtual void DecodeOptions(const GoogleUrl& request_url,
00082                              const RequestHeaders& request_headers,
00083                              Callback* callback,
00084                              MessageHandler* handler) const;
00085 
00087   virtual void PrepareRequest(const RewriteOptions* rewrite_options,
00088                               GoogleString* url,
00089                               RequestHeaders* request_headers,
00090                               bool* success,
00091                               Function* func, MessageHandler* handler);
00092 
00094   virtual void ConfigureCustomOptions(const RequestHeaders& request_headers,
00095                                       RewriteOptions* options) const {}
00096 
00099   virtual bool ProxyMode() const { return false; }
00100 
00103   virtual bool IsProxyEncoded(const GoogleUrl& url) const { return false; }
00104 
00105   const GoogleString& get_proxy_domain() {
00106     return proxy_domain_;
00107   }
00108 
00109   void set_proxy_domain(const GoogleString proxy_domain) {
00110     proxy_domain_ = proxy_domain;
00111   }
00112 
00113  private:
00114   GoogleString proxy_domain_;
00115 
00116   DISALLOW_COPY_AND_ASSIGN(UrlNamer);
00117 };
00118 
00119 }  
00120 
00121 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_URL_NAMER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines