00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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_;
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_