Page Speed Optimization Libraries  1.4.26.1
net/instaweb/rewriter/public/rewrite_filter.h
Go to the documentation of this file.
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 
00018 
00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_FILTER_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_FILTER_H_
00021 
00022 #include "net/instaweb/rewriter/public/common_filter.h"
00023 #include "net/instaweb/rewriter/public/resource_slot.h"
00024 #include "net/instaweb/rewriter/public/rewrite_options.h"
00025 #include "net/instaweb/util/public/basictypes.h"
00026 #include "net/instaweb/util/public/string.h"
00027 #include "net/instaweb/util/public/string_util.h"
00028 
00029 namespace net_instaweb {
00030 
00031 class Resource;
00032 class ResourceContext;
00033 class RewriteContext;
00034 class RewriteDriver;
00035 class UrlSegmentEncoder;
00036 
00037 class RewriteFilter : public CommonFilter {
00038  public:
00039   explicit RewriteFilter(RewriteDriver* driver)
00040       : CommonFilter(driver) {
00041   }
00042   virtual ~RewriteFilter();
00043 
00044   virtual const char* id() const = 0;
00045 
00050   virtual void DetermineEnabled();
00051 
00056   virtual const UrlSegmentEncoder* encoder() const;
00057 
00064   virtual bool ComputeOnTheFly() const;
00065 
00069   virtual RewriteContext* MakeRewriteContext();
00070 
00074   virtual RewriteContext* MakeNestedRewriteContext(
00075       RewriteContext* parent, const ResourceSlotPtr& slot);
00076 
00080   virtual void EncodeUserAgentIntoResourceContext(
00081       ResourceContext* context) const {}
00082 
00095   static StringPiece GetCharsetForScript(const Resource* script,
00096                                          const StringPiece attribute_charset,
00097                                          const StringPiece enclosing_charset);
00098 
00111   static GoogleString GetCharsetForStylesheet(
00112       const Resource* stylesheet,
00113       const StringPiece attribute_charset,
00114       const StringPiece enclosing_charset);
00115 
00131   virtual const RewriteOptions::Filter* RelatedFilters(int* num_filters) const;
00132 
00142   virtual const RewriteOptions::OptionEnum* RelatedOptions(
00143       int* num_options) const;
00144 
00145  protected:
00147   virtual const char* LoggingId() { return id(); }
00148 
00149  private:
00154   virtual bool UsesPropertyCacheDomCohort() const { return false; }
00155 
00156   DISALLOW_COPY_AND_ASSIGN(RewriteFilter);
00157 };
00158 
00159 }  
00160 
00161 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_REWRITE_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines