Page Speed Optimization Libraries  1.7.30.2
net/instaweb/rewriter/public/beacon_critical_images_finder.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  */
00017 
00018 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_BEACON_CRITICAL_IMAGES_FINDER_H_
00019 #define NET_INSTAWEB_REWRITER_PUBLIC_BEACON_CRITICAL_IMAGES_FINDER_H_
00020 
00021 #include "net/instaweb/rewriter/public/critical_finder_support_util.h"
00022 #include "net/instaweb/rewriter/public/critical_images_finder.h"
00023 #include "net/instaweb/util/public/property_cache.h"
00024 #include "net/instaweb/util/public/string.h"
00025 #include "pagespeed/kernel/base/string_util.h"
00026 
00027 namespace net_instaweb {
00028 
00029 class NonceGenerator;
00030 class RenderedImages;
00031 class RewriteDriver;
00032 class Statistics;
00033 class Timer;
00034 
00037 class BeaconCriticalImagesFinder : public CriticalImagesFinder {
00038  public:
00040   BeaconCriticalImagesFinder(
00041       const PropertyCache::Cohort* cohort,
00042       NonceGenerator* nonce_generator,
00043       Statistics* stats);
00044   virtual ~BeaconCriticalImagesFinder();
00045 
00046   virtual bool IsMeaningful(const RewriteDriver* driver) const;
00047 
00048   virtual int PercentSeenForCritical() const {
00049     return kBeaconPercentSeenForCritical;
00050   }
00051 
00052   virtual int SupportInterval() const {
00053     return kBeaconImageSupportInterval;
00054   }
00055 
00056   virtual void ComputeCriticalImages(RewriteDriver* driver) {}
00057 
00060   static bool UpdateCriticalImagesCacheEntry(
00061       const StringSet* html_critical_images_set,
00062       const StringSet* css_critical_images_set,
00063       const RenderedImages* rendered_images_set,
00064       const StringPiece& nonce,
00065       const PropertyCache::Cohort* cohort,
00066       AbstractPropertyPage* page,
00067       Timer* timer);
00068 
00072   virtual BeaconMetadata PrepareForBeaconInsertion(RewriteDriver* driver);
00073 
00074  private:
00075   virtual GoogleString GetKeyForUrl(const GoogleString& url);
00076 
00078   static const int kBeaconPercentSeenForCritical = 80;
00080   static const int kBeaconImageSupportInterval = 10;
00081 
00082   NonceGenerator* nonce_generator_;
00083 };
00084 
00085 }  
00086 
00087 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_BEACON_CRITICAL_IMAGES_FINDER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines