19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_IMAGES_FINDER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_IMAGES_FINDER_H_
25 #include "net/instaweb/rewriter/critical_images.pb.h"
27 #include "net/instaweb/util/public/property_cache.h"
32 namespace net_instaweb {
41 typedef std::map<GoogleString, std::pair<int32, int32> >
42 RenderedImageDimensionsMap;
54 : is_critical_image_info_present(
false) {}
55 StringSet html_critical_images;
56 StringSet css_critical_images;
58 bool is_critical_image_info_present;
59 RenderedImageDimensionsMap rendered_images_map;
72 static const char kCriticalImagesValidCount[];
73 static const char kCriticalImagesExpiredCount[];
74 static const char kCriticalImagesNotFoundCount[];
75 static const char kCriticalImagesPropertyName[];
96 return kDefaultPercentSeenForCritical;
107 return kDefaultImageSupportInterval;
122 bool IsCssCriticalImage(StringPiece image_url,
RewriteDriver* driver);
129 std::pair<int32, int32>* dimensions);
134 const StringSet& GetCssCriticalImages(
RewriteDriver* driver);
143 StringSet* mutable_css_critical_images(
RewriteDriver* driver);
160 const StringSet* html_critical_images_set,
161 const StringSet* css_critical_images_set,
169 const PropertyValue* property_value, CriticalImages* critical_images);
175 const StringSet* html_critical_images_set,
176 const StringSet* css_critical_images_set,
177 const RenderedImages* rendered_images_set,
178 int support_interval,
209 result.status = kBeaconNoNonce;
226 const StringSet* html_critical_images_set,
227 const StringSet* css_critical_images_set,
228 const RenderedImages* rendered_images_set,
229 int support_interval,
232 CriticalImages* critical_images);
240 virtual GoogleString GetKeyForUrl(StringPiece url) {
return url.as_string(); }
246 RewriteDriver* driver,
247 const PropertyValue* property_value);
250 friend class CriticalImagesFinderTestBase;
256 static bool UpdateCriticalImages(
const StringSet* html_critical_images,
257 const StringSet* css_critical_images,
258 int support_interval,
259 CriticalImages* critical_images);
263 static const int kDefaultPercentSeenForCritical = 100;
264 static const int kDefaultImageSupportInterval = 1;
266 const PropertyCache::Cohort* cohort_;
268 Variable* critical_images_valid_count_;
269 Variable* critical_images_expired_count_;
270 Variable* critical_images_not_found_count_;
class GoogleUrl
Definition: google_url.h:58
Abstract interface for implementing a PropertyPage.
Definition: property_cache.h:291
Data is expected but we don't have it yet.
Definition: critical_images_finder.h:69
Holds the value & stability-metadata for a property.
Definition: property_cache.h:122
virtual int SupportInterval() const
Definition: critical_images_finder.h:106
Definition: property_cache.h:186
Definition: critical_images_finder.h:65
virtual bool ShouldBeacon(RewriteDriver *driver)
Definition: critical_images_finder.h:201
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
static bool UpdateCriticalImagesCacheEntry(const StringSet *html_critical_images_set, const StringSet *css_critical_images_set, const RenderedImages *rendered_images_set, int support_interval, const PropertyCache::Cohort *cohort, AbstractPropertyPage *page)
const PropertyCache::Cohort * cohort() const
Definition: critical_images_finder.h:152
virtual void ComputeCriticalImages(RewriteDriver *driver)=0
Compute the critical images for the driver's url.
bool GetRenderedImageDimensions(RewriteDriver *driver, const GoogleUrl &image_src_gurl, std::pair< int32, int32 > *dimensions)
virtual BeaconMetadata PrepareForBeaconInsertion(RewriteDriver *driver)
Definition: critical_images_finder.h:207
const StringSet & GetHtmlCriticalImages(RewriteDriver *driver)
static bool PopulateCriticalImagesFromPropertyValue(const PropertyValue *property_value, CriticalImages *critical_images)
void AddHtmlCriticalImage(const GoogleString &url, RewriteDriver *driver)
Adds the given url to the html critical image set for the driver.
virtual void UpdateCandidateImagesForBeaconing(const StringSet &images, RewriteDriver *driver, bool beaconing)
Definition: critical_images_finder.h:218
Availability
Definition: critical_images_finder.h:67
static bool UpdateAndWriteBackCriticalImagesCacheEntry(const StringSet *html_critical_images_set, const StringSet *css_critical_images_set, const RenderedImages *rendered_images_set, int support_interval, const PropertyCache::Cohort *cohort, AbstractPropertyPage *page, CriticalImages *critical_images)
RenderedImages * JsonMapToRenderedImagesMap(const GoogleString &str, const RewriteOptions *options)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
StringSet * mutable_html_critical_images(RewriteDriver *driver)
Data will never be forthcoming.
Definition: critical_images_finder.h:68
Data is available.
Definition: critical_images_finder.h:70
virtual bool IsCriticalImageInfoPresent(RewriteDriver *driver)
Definition: rewrite_driver.h:100
virtual void UpdateCriticalImagesSetInDriver(RewriteDriver *driver)
virtual int PercentSeenForCritical() const
Definition: critical_images_finder.h:95
CriticalImagesInfo * ExtractCriticalImagesFromCache(RewriteDriver *driver, const PropertyValue *property_value)
bool UpdateCriticalImagesCacheEntryFromDriver(const StringSet *html_critical_images_set, const StringSet *css_critical_images_set, RewriteDriver *driver)
bool IsHtmlCriticalImage(StringPiece image_url, RewriteDriver *driver)
Definition: rewrite_options.h:84
virtual RenderedImages * ExtractRenderedImageDimensionsFromCache(RewriteDriver *driver)
Extracts rendered images' dimensions from property cache.
virtual Availability Available(RewriteDriver *driver)
Definition: critical_images_finder.h:52
static const char kRenderedImageDimensionsProperty[]
Definition: critical_images_finder.h:78