Page Speed Optimization Libraries  1.7.30.2
net/instaweb/rewriter/public/css_image_rewriter.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_CSS_IMAGE_REWRITER_H_
00020 #define NET_INSTAWEB_REWRITER_PUBLIC_CSS_IMAGE_REWRITER_H_
00021 
00022 #include <cstddef>
00023 
00024 #include "net/instaweb/rewriter/public/css_filter.h"
00025 #include "net/instaweb/rewriter/public/resource_slot.h"
00026 #include "net/instaweb/util/public/basictypes.h"
00027 
00028 namespace Css {
00029 
00030 class Values;
00031 
00032 }  
00033 
00034 namespace net_instaweb {
00035 
00036 class CacheExtender;
00037 class CssHierarchy;
00038 class GoogleUrl;
00039 class ImageCombineFilter;
00040 class ImageRewriteFilter;
00041 class MessageHandler;
00042 class RewriteContext;
00043 class RewriteDriver;
00044 class Statistics;
00045 
00046 class CssImageRewriter {
00047  public:
00048   CssImageRewriter(CssFilter::Context* root_context,
00049                    CssFilter* filter,
00050                    RewriteDriver* driver,
00051                    CacheExtender* cache_extender,
00052                    ImageRewriteFilter* image_rewriter,
00053                    ImageCombineFilter* image_combiner);
00054   ~CssImageRewriter();
00055 
00056   static void InitStats(Statistics* statistics);
00057 
00062   bool RewriteCss(int64 image_inline_max_bytes,
00063                   RewriteContext* parent,
00064                   CssHierarchy* hierarchy,
00065                   MessageHandler* handler);
00066 
00068   bool FlatteningEnabled() const;
00069 
00071   bool RewritesEnabled(int64 image_inline_max_bytes) const;
00072 
00075   void RewriteSlot(const ResourceSlotPtr& slot,
00076                    int64 image_inline_max_bytes,
00077                    RewriteContext* parent);
00078 
00079  private:
00080   bool RewriteImport(RewriteContext* parent,
00081                      CssHierarchy* hierarchy);
00082 
00083   void RewriteImage(int64 image_inline_max_bytes,
00084                     const GoogleUrl& trim_url,
00085                     const GoogleUrl& original_url,
00086                     RewriteContext* parent,
00087                     Css::Values* values, size_t value_index);
00088 
00090   CssFilter* filter_;
00091 
00093   RewriteDriver* driver_;
00094 
00096   CssFilter::Context* root_context_;
00097 
00101   CacheExtender* cache_extender_;
00102   ImageCombineFilter* image_combiner_;
00103   ImageRewriteFilter* image_rewriter_;
00104 
00105   DISALLOW_COPY_AND_ASSIGN(CssImageRewriter);
00106 };
00107 
00108 }  
00109 
00110 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_CSS_IMAGE_REWRITER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines