Page Speed Optimization Libraries  1.6.29.3
net/instaweb/rewriter/public/file_load_mapping.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 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_FILE_LOAD_MAPPING_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/manually_ref_counted.h"
00024 #include "net/instaweb/util/public/re2.h"
00025 #include "net/instaweb/util/public/string.h"
00026 #include "net/instaweb/util/public/string_util.h"
00027 
00028 namespace net_instaweb {
00029 
00032 class FileLoadMapping : public ManuallyRefCounted {
00033  public:
00034   virtual ~FileLoadMapping();
00035 
00038   virtual bool Substitute(const StringPiece& url,
00039                           GoogleString* filename) const = 0;
00040 };
00041 
00042 class FileLoadMappingRegexp : public FileLoadMapping {
00043  public:
00044   FileLoadMappingRegexp(const GoogleString& url_regexp,
00045                         const GoogleString& filename_prefix)
00046       : url_regexp_(url_regexp),
00047         url_regexp_str_(url_regexp),
00048         filename_prefix_(filename_prefix) {}
00049 
00050   virtual bool Substitute(const StringPiece& url, GoogleString* filename) const;
00051 
00052  private:
00053   const RE2 url_regexp_;
00055   const GoogleString url_regexp_str_;
00056   const GoogleString filename_prefix_;
00057 
00058   DISALLOW_COPY_AND_ASSIGN(FileLoadMappingRegexp);
00059 };
00060 
00061 class FileLoadMappingLiteral : public FileLoadMapping {
00062  public:
00063   FileLoadMappingLiteral(const GoogleString& url_prefix,
00064                          const GoogleString& filename_prefix)
00065       : url_prefix_(url_prefix),
00066         filename_prefix_(filename_prefix) {}
00067 
00068   virtual bool Substitute(const StringPiece& url, GoogleString* filename) const;
00069 
00070  private:
00071   const GoogleString url_prefix_;
00072   const GoogleString filename_prefix_;
00073 
00074   DISALLOW_COPY_AND_ASSIGN(FileLoadMappingLiteral);
00075 };
00076 
00077 }  
00078 
00079 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_FILE_LOAD_MAPPING_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines