Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
beacon_critical_images_finder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
17 
18 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_BEACON_CRITICAL_IMAGES_FINDER_H_
19 #define NET_INSTAWEB_REWRITER_PUBLIC_BEACON_CRITICAL_IMAGES_FINDER_H_
20 
23 #include "net/instaweb/util/public/property_cache.h"
26 
27 namespace net_instaweb {
28 
29 class NonceGenerator;
30 class RenderedImages;
31 class RewriteDriver;
32 class Statistics;
33 class Timer;
34 
38  public:
42  NonceGenerator* nonce_generator,
43  Statistics* stats);
44  virtual ~BeaconCriticalImagesFinder();
45 
46  virtual Availability Available(RewriteDriver* driver);
47 
48  virtual int PercentSeenForCritical() const {
49  return kBeaconPercentSeenForCritical;
50  }
51 
52  virtual int SupportInterval() const {
53  return kBeaconImageSupportInterval;
54  }
55 
56  virtual void ComputeCriticalImages(RewriteDriver* driver) {}
57 
61  const StringSet* html_critical_images_set,
62  const StringSet* css_critical_images_set,
63  const RenderedImages* rendered_images_set,
64  const StringPiece& nonce,
65  const PropertyCache::Cohort* cohort,
67  Timer* timer);
68 
69  virtual bool ShouldBeacon(RewriteDriver* driver);
74 
75  virtual void UpdateCandidateImagesForBeaconing(const StringSet& images,
76  RewriteDriver* driver,
77  bool beaconing);
78 
79  private:
80  virtual GoogleString GetKeyForUrl(StringPiece url);
81 
83  static const int kBeaconPercentSeenForCritical = 80;
85  static const int kBeaconImageSupportInterval = 10;
86 
87  NonceGenerator* nonce_generator_;
88 };
89 
90 }
91 
92 #endif
Abstract interface for implementing a PropertyPage.
Definition: property_cache.h:291
virtual void ComputeCriticalImages(RewriteDriver *driver)
Compute the critical images for the driver's url.
Definition: beacon_critical_images_finder.h:56
Definition: property_cache.h:186
Definition: critical_images_finder.h:65
virtual void UpdateCandidateImagesForBeaconing(const StringSet &images, RewriteDriver *driver, bool beaconing)
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, const StringPiece &nonce, const PropertyCache::Cohort *cohort, AbstractPropertyPage *page, Timer *timer)
Definition: beacon_critical_images_finder.h:37
const PropertyCache::Cohort * cohort() const
Definition: critical_images_finder.h:152
BeaconCriticalImagesFinder(const PropertyCache::Cohort *cohort, NonceGenerator *nonce_generator, Statistics *stats)
All constructor args are owned by the caller.
virtual bool ShouldBeacon(RewriteDriver *driver)
Availability
Definition: critical_images_finder.h:67
virtual Availability Available(RewriteDriver *driver)
Definition: critical_finder_support_util.h:78
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual BeaconMetadata PrepareForBeaconInsertion(RewriteDriver *driver)
Definition: rewrite_driver.h:100
virtual int PercentSeenForCritical() const
Definition: beacon_critical_images_finder.h:48
Definition: nonce_generator.h:28
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
virtual int SupportInterval() const
Definition: beacon_critical_images_finder.h:52