Page Speed Optimization Libraries  1.8.31.2
net/instaweb/rewriter/public/url_partnership.h
00001 /*
00002  * Copyright 2010 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 
00017 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_URL_PARTNERSHIP_H_
00018 #define NET_INSTAWEB_REWRITER_PUBLIC_URL_PARTNERSHIP_H_
00019 
00020 #include <vector>
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/google_url.h"
00024 #include "net/instaweb/util/public/string.h"
00025 #include "net/instaweb/util/public/string_util.h"
00026 
00027 namespace net_instaweb {
00028 
00029 class MessageHandler;
00030 class RewriteDriver;
00031 class RewriteOptions;
00032 class UrlNamer;
00033 
00041 class UrlPartnership {
00042  public:
00043   explicit UrlPartnership(const RewriteDriver* driver);
00044   virtual ~UrlPartnership();
00045 
00048   bool AddUrl(const StringPiece& resource_url, MessageHandler* handler);
00049 
00052   GoogleString ResolvedBase() const;
00053 
00055   int num_urls() const { return url_vector_.size(); }
00056 
00059   GoogleString RelativePath(int index) const;
00060 
00062   const GoogleUrl* FullPath(int index) const { return url_vector_[index]; }
00063 
00065   void RemoveLast();
00066 
00070   virtual void Reset(const GoogleUrl& original_request);
00071 
00074   int NumCommonComponents() const { return common_components_.size(); }
00075 
00076  protected:
00077   const RewriteOptions* rewrite_options() const { return rewrite_options_; }
00078 
00079  private:
00083   void IncrementalResolve(int index);
00084 
00089   bool FindResourceDomain(GoogleUrl* resource,
00090                           GoogleString* domain,
00091                           MessageHandler* handler) const;
00092 
00093   typedef std::vector<GoogleUrl*> GurlVector;
00094   GurlVector url_vector_;
00095   GoogleString domain_and_path_prefix_;
00096   const RewriteOptions* rewrite_options_;
00097   const UrlNamer* url_namer_;
00098   GoogleUrl original_origin_and_path_;
00099 
00102   StringVector common_components_;
00103 
00104   DISALLOW_COPY_AND_ASSIGN(UrlPartnership);
00105 };
00106 
00107 }  
00108 
00109 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_URL_PARTNERSHIP_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines