Page Speed Optimization Libraries  1.3.25.1
net/instaweb/rewriter/public/delay_images_filter.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 
00070 
00071 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_
00072 #define NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_
00073 
00074 #include "net/instaweb/htmlparse/public/empty_html_filter.h"
00075 #include "net/instaweb/util/public/basictypes.h"
00076 #include "net/instaweb/util/public/string_util.h"
00077 
00078 namespace net_instaweb {
00079 
00080 class HtmlElement;
00081 class RewriteDriver;
00082 class StaticAssetManager;
00083 class Statistics;
00084 
00085 class DelayImagesFilter : public EmptyHtmlFilter {
00086  public:
00087   static const char kDelayImagesSuffix[];
00088   static const char kDelayImagesInlineSuffix[];
00089   static const char kOnloadFunction[];
00090 
00091   explicit DelayImagesFilter(RewriteDriver* driver);
00092   virtual ~DelayImagesFilter();
00093 
00094   virtual void StartDocument();
00095   virtual void EndDocument();
00096   virtual void EndElement(HtmlElement* element);
00097 
00098   virtual const char* Name() const { return "DelayImages"; }
00099 
00100   static void InitStats(Statistics* statistics);
00101   static void Terminate();
00102 
00103  private:
00106   void InsertDelayImagesJS(HtmlElement* element);
00107 
00110   void InsertDelayImagesInlineJS(HtmlElement* element);
00111 
00114   bool DisableInplaceLowResForMobile() const;
00115 
00116   RewriteDriver* driver_;
00117   StaticAssetManager* static_asset_manager_;
00118 
00122   bool low_res_map_inserted_;
00123   int num_low_res_inlined_images_;
00124   StringStringMap low_res_data_map_;
00125 
00129   bool insert_low_res_images_inplace_;
00130 
00133   bool is_experimental_enabled_;
00134   DISALLOW_COPY_AND_ASSIGN(DelayImagesFilter);
00135 };
00136 
00137 }  
00138 
00139 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines