Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
critical_selector_finder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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  */
16 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_SELECTOR_FINDER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_SELECTOR_FINDER_H_
21 
22 #include "net/instaweb/rewriter/critical_keys.pb.h"
24 #include "net/instaweb/util/public/property_cache.h"
28 
29 namespace net_instaweb {
30 
31 class MessageHandler;
32 class NonceGenerator;
33 class RewriteDriver;
34 class Statistics;
35 class TimedVariable;
36 class Timer;
37 
44  StringSet critical_selectors;
45  CriticalKeys proto;
46 };
47 
52  public:
53  static const char kCriticalSelectorsValidCount[];
54  static const char kCriticalSelectorsExpiredCount[];
55  static const char kCriticalSelectorsNotFoundCount[];
56  static const char kCriticalSelectorsPropertyName[];
57 
63  NonceGenerator* nonce_generator, Statistics* stats);
64  virtual ~CriticalSelectorFinder();
65 
66  static void InitStats(Statistics* statistics);
67 
68  bool IsCriticalSelector(RewriteDriver* driver, const GoogleString& selector);
69 
70  const StringSet& GetCriticalSelectors(RewriteDriver* driver);
71 
78  const StringSet& selector_set, StringPiece nonce,
79  RewriteDriver* driver);
80 
84  const StringSet& selector_set, StringPiece nonce, int support_interval,
85  bool should_replace_prior_result, const PropertyCache* cache,
86  const PropertyCache::Cohort* cohort, AbstractPropertyPage* page,
87  MessageHandler* message_handler, Timer* timer);
88 
95  const StringSet& selector_set, RewriteDriver* driver);
96 
98  virtual int SupportInterval() const = 0;
99 
100  protected:
102  virtual bool ShouldReplacePriorResult() const { return false; }
103 
106 
107  private:
111  void UpdateCriticalSelectorInfoInDriver(RewriteDriver* driver);
112 
113  const PropertyCache::Cohort* cohort_;
114  NonceGenerator* nonce_generator_;
115 
116  TimedVariable* critical_selectors_valid_count_;
117  TimedVariable* critical_selectors_expired_count_;
118  TimedVariable* critical_selectors_not_found_count_;
119 
120 
121 };
122 
124  public:
126  NonceGenerator* nonce_generator,
127  Statistics* stats)
128  : CriticalSelectorFinder(cohort, nonce_generator, stats) {}
129 
130  static void WriteCriticalSelectorsToPropertyCacheFromBeacon(
131  const StringSet& selector_set, StringPiece nonce,
132  const PropertyCache* cache, const PropertyCache::Cohort* cohort,
133  AbstractPropertyPage* page, MessageHandler* message_handler,
134  Timer* timer);
135 
136  private:
138  static const int kDefaultSupportInterval = 10;
139 
141  virtual int SupportInterval() const { return kDefaultSupportInterval; }
142 };
143 
144 }
145 
146 #endif
Abstract interface for implementing a PropertyPage.
Definition: property_cache.h:291
Definition: critical_selector_finder.h:43
Definition: property_cache.h:186
Adds property-semantics to a raw cache API.
Definition: property_cache.h:180
Definition: critical_selector_finder.h:123
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
CriticalSelectorFinder(const PropertyCache::Cohort *cohort, NonceGenerator *nonce_generator, Statistics *stats)
virtual void WriteCriticalSelectorsToPropertyCache(const StringSet &selector_set, StringPiece nonce, RewriteDriver *driver)
Definition: critical_selector_finder.h:51
BeaconMetadata PrepareForBeaconInsertion(const StringSet &selector_set, RewriteDriver *driver)
Definition: critical_finder_support_util.h:78
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: rewrite_driver.h:100
Definition: message_handler.h:39
virtual int SupportInterval() const =0
Gets the SupportInterval for a new beacon result.
Definition: statistics.h:298
Definition: nonce_generator.h:28
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27
static void WriteCriticalSelectorsToPropertyCacheStatic(const StringSet &selector_set, StringPiece nonce, int support_interval, bool should_replace_prior_result, const PropertyCache *cache, const PropertyCache::Cohort *cohort, AbstractPropertyPage *page, MessageHandler *message_handler, Timer *timer)
virtual bool ShouldReplacePriorResult() const
Returns true if a beacon result should replace all previous results.
Definition: critical_selector_finder.h:102