Page Speed Optimization Libraries
1.6.29.3
|
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_images_finder.h" 00022 #include "net/instaweb/util/public/property_cache.h" 00023 #include "net/instaweb/util/public/string.h" 00024 #include "pagespeed/kernel/base/string_util.h" 00025 00026 namespace net_instaweb { 00027 00028 class NonceGenerator; 00029 class RewriteDriver; 00030 class Statistics; 00031 00034 class BeaconCriticalImagesFinder : public CriticalImagesFinder { 00035 public: 00037 BeaconCriticalImagesFinder( 00038 const PropertyCache::Cohort* cohort, 00039 NonceGenerator* nonce_generator, 00040 Statistics* stats); 00041 virtual ~BeaconCriticalImagesFinder(); 00042 00043 virtual bool IsMeaningful(const RewriteDriver* driver) const; 00044 00045 virtual int PercentSeenForCritical() const { 00046 return kBeaconPercentSeenForCritical; 00047 } 00048 00049 virtual int NumSetsToKeep() const { 00050 return kBeaconNumSetsToKeep; 00051 } 00052 00053 virtual void ComputeCriticalImages(RewriteDriver* driver) {} 00054 00055 virtual const PropertyCache::Cohort* GetCriticalImagesCohort() const { 00056 return cohort_; 00057 } 00058 00061 static bool UpdateCriticalImagesCacheEntry( 00062 const StringSet* html_critical_images_set, 00063 const StringSet* css_critical_images_set, 00064 const PropertyCache::Cohort* cohort, 00065 AbstractPropertyPage* page); 00066 00067 private: 00068 virtual GoogleString GetKeyForUrl(const GoogleString& url); 00069 00071 static const int kBeaconPercentSeenForCritical = 80; 00073 static const int kBeaconNumSetsToKeep = 10; 00074 00075 const PropertyCache::Cohort* cohort_; 00076 NonceGenerator* nonce_generator_; 00077 }; 00078 00079 } 00080 00081 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_BEACON_CRITICAL_IMAGES_FINDER_H_