Page Speed Optimization Libraries
1.7.30.1
|
#include "beacon_critical_images_finder.h"
Public Member Functions | |
BeaconCriticalImagesFinder (const PropertyCache::Cohort *cohort, NonceGenerator *nonce_generator, Statistics *stats) | |
All constructor args are owned by the caller. | |
virtual bool | IsMeaningful (const RewriteDriver *driver) const |
virtual int | PercentSeenForCritical () const |
virtual int | SupportInterval () const |
virtual void | ComputeCriticalImages (RewriteDriver *driver) |
Compute the critical images for the driver's url. | |
virtual BeaconMetadata | PrepareForBeaconInsertion (RewriteDriver *driver) |
Static Public Member Functions | |
static bool | UpdateCriticalImagesCacheEntry (const StringSet *html_critical_images_set, const StringSet *css_critical_images_set, const RenderedImages *rendered_images_set, const StringPiece &nonce, const PropertyCache::Cohort *cohort, AbstractPropertyPage *page, Timer *timer) |
Support critical (above the fold) image detection through a javascript beacon on the client.
virtual bool net_instaweb::BeaconCriticalImagesFinder::IsMeaningful | ( | const RewriteDriver * | driver | ) | const [virtual] |
Checks whether IsHtmlCriticalImage will return meaningful results about critical images. Users of IsHtmlCriticalImage should check this function and supply a default behavior if IsMeaningful returns false.
Implements net_instaweb::CriticalImagesFinder.
virtual int net_instaweb::BeaconCriticalImagesFinder::PercentSeenForCritical | ( | ) | const [inline, virtual] |
In order to handle varying critical image sets returned by the beacon, we store a history of the last N critical images, and only declare an image critical if it appears critical in the last M out of N sets reported. This function returns what percentage of the sets need to include the image for it be considered critical.
Reimplemented from net_instaweb::CriticalImagesFinder.
virtual BeaconMetadata net_instaweb::BeaconCriticalImagesFinder::PrepareForBeaconInsertion | ( | RewriteDriver * | driver | ) | [virtual] |
Check beacon interval and nonce state, and return appropriate BeaconMetadata; result.status indicates whether beaconing should occur, and result.nonce contains the nonce (if required).
Reimplemented from net_instaweb::CriticalImagesFinder.
virtual int net_instaweb::BeaconCriticalImagesFinder::SupportInterval | ( | ) | const [inline, virtual] |
Minimum interval to store support for critical image results. This affects how long we keep around evidence that an image might be critical; we'll remember the fact for at least SupportInterval beacon insertions if it only occurs once, and we'll remember it longer if multiple beacons support image criticality. By default, SupportInteval() = 1 and we only store one beacon result. The beacon critical image finder should override this to store a larger number of sets.
Reimplemented from net_instaweb::CriticalImagesFinder.
static bool net_instaweb::BeaconCriticalImagesFinder::UpdateCriticalImagesCacheEntry | ( | const StringSet * | html_critical_images_set, |
const StringSet * | css_critical_images_set, | ||
const RenderedImages * | rendered_images_set, | ||
const StringPiece & | nonce, | ||
const PropertyCache::Cohort * | cohort, | ||
AbstractPropertyPage * | page, | ||
Timer * | timer | ||
) | [static] |
Update the critical image entry in the property cache. This is meant to be called in the beacon handler, where there is no RewriteDriver available.