Page Speed Optimization Libraries  1.8.31.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                    CacheExtender* cache_extender,
00051                    ImageRewriteFilter* image_rewriter,
00052                    ImageCombineFilter* image_combiner);
00053   ~CssImageRewriter();
00054 
00055   static void InitStats(Statistics* statistics);
00056 
00061   bool RewriteCss(int64 image_inline_max_bytes,
00062                   RewriteContext* parent,
00063                   CssHierarchy* hierarchy,
00064                   MessageHandler* handler);
00065 
00067   bool FlatteningEnabled() const;
00068 
00070   bool RewritesEnabled(int64 image_inline_max_bytes) const;
00071 
00074   void RewriteSlot(const ResourceSlotPtr& slot,
00075                    int64 image_inline_max_bytes,
00076                    RewriteContext* parent);
00077 
00078  private:
00079   RewriteDriver* driver() const {
00080     return filter_->driver();
00081   }
00082   bool RewriteImport(RewriteContext* parent,
00083                      CssHierarchy* hierarchy);
00084 
00085   void RewriteImage(int64 image_inline_max_bytes,
00086                     const GoogleUrl& trim_url,
00087                     const GoogleUrl& original_url,
00088                     RewriteContext* parent,
00089                     Css::Values* values, size_t value_index);
00090 
00092   CssFilter* filter_;
00093 
00095   CssFilter::Context* root_context_;
00096 
00100   CacheExtender* cache_extender_;
00101   ImageCombineFilter* image_combiner_;
00102   ImageRewriteFilter* image_rewriter_;
00103 
00104   DISALLOW_COPY_AND_ASSIGN(CssImageRewriter);
00105 };
00106 
00107 }  
00108 
00109 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_CSS_IMAGE_REWRITER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines