Page Speed Optimization Libraries
1.3.25.1
|
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 */ 00016 00018 00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_IMAGES_FINDER_H_ 00020 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_IMAGES_FINDER_H_ 00021 00022 #include "net/instaweb/util/public/basictypes.h" 00023 #include "net/instaweb/util/public/string.h" 00024 #include "net/instaweb/util/public/string_util.h" 00025 00026 namespace net_instaweb { 00027 00028 class PropertyCache; 00029 class PropertyPage; 00030 class PropertyValue; 00031 class RewriteDriver; 00032 class Statistics; 00033 class Variable; 00034 00037 class CriticalImagesFinder { 00038 public: 00039 static const char kCriticalImagesValidCount[]; 00040 static const char kCriticalImagesExpiredCount[]; 00041 static const char kCriticalImagesNotFoundCount[]; 00042 00043 explicit CriticalImagesFinder(Statistics* stats); 00044 virtual ~CriticalImagesFinder(); 00045 00046 static void InitStats(Statistics* statistics); 00047 00051 virtual bool IsMeaningful(const RewriteDriver* driver) const = 0; 00052 00057 virtual bool IsCriticalImage(const GoogleString& image_url, 00058 const RewriteDriver* driver) const; 00059 00062 virtual void UpdateCriticalImagesSetInDriver(RewriteDriver* driver); 00063 00065 virtual void ComputeCriticalImages(StringPiece url, 00066 RewriteDriver* driver) = 0; 00067 00070 virtual const char* GetCriticalImagesCohort() const = 0; 00071 00076 bool UpdateCriticalImagesCacheEntryFromDriver( 00077 RewriteDriver* driver, 00078 StringSet* critical_images_set, 00079 StringSet* css_critical_images_set); 00080 00085 bool UpdateCriticalImagesCacheEntry( 00086 PropertyPage* page, 00087 PropertyCache* page_property_cache, 00088 StringSet* critical_images_set, 00089 StringSet* css_critical_images_set); 00090 00091 private: 00092 static const char kCriticalImagesPropertyName[]; 00093 static const char kCssCriticalImagesPropertyName[]; 00094 00098 StringSet* ExtractCriticalImagesSet( 00099 RewriteDriver* driver, 00100 const PropertyValue* property_value, 00101 bool track_stats); 00102 00103 Variable* critical_images_valid_count_; 00104 Variable* critical_images_expired_count_; 00105 Variable* critical_images_not_found_count_; 00106 00107 friend class CriticalImagesFinderTestBase; 00108 DISALLOW_COPY_AND_ASSIGN(CriticalImagesFinder); 00109 }; 00110 00111 } 00112 00113 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_IMAGES_FINDER_H_