Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
critical_finder_support_util.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 
34 
35 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_FINDER_SUPPORT_UTIL_H_
36 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_FINDER_SUPPORT_UTIL_H_
37 
38 #include "net/instaweb/rewriter/critical_keys.pb.h"
39 #include "net/instaweb/util/public/property_cache.h"
44 
45 namespace net_instaweb {
46 
50 const int64 kBeaconTimeoutIntervalMs = Timer::kMinuteMs;
51 
54 const int64 kHighFreqBeaconCount = 3;
55 
61 const int64 kLowFreqBeaconMult = 100;
62 
66 const int64 kNonceExpirationLimit = 5;
67 
68 class MessageHandler;
69 class NonceGenerator;
70 class RewriteDriver;
71 
72 enum BeaconStatus {
73  kDoNotBeacon,
74  kBeaconNoNonce,
75  kBeaconWithNonce
76 };
77 
79  BeaconMetadata() : status(kDoNotBeacon) { }
80  BeaconStatus status;
81  GoogleString nonce;
82 };
83 
89 bool ValidateAndExpireNonce(int64 now_ms, StringPiece nonce,
90  CriticalKeys* critical_keys);
91 
98 void GetCriticalKeysFromProto(int64 support_percentage,
99  const CriticalKeys& critical_keys,
100  StringSet* keys);
101 
107 void UpdateCriticalKeys(bool require_prior_support,
108  const StringSet& new_set, int support_value,
109  CriticalKeys* critical_keys);
110 
111 bool ShouldBeacon(int64 next_beacon_timestamp_ms, const RewriteDriver& driver);
112 
115  kReplacePriorResult = 1,
116  kRequirePriorSupport = 2,
117  kSkipNonceCheck = 4
118 };
119 
128  const StringSet& new_keys, StringPiece nonce, int support_interval,
130  StringPiece property_name, const PropertyCache* cache,
131  const PropertyCache::Cohort* cohort, AbstractPropertyPage* page,
132  MessageHandler* message_handler, Timer* timer);
133 
147 void PrepareForBeaconInsertionHelper(CriticalKeys* proto,
148  NonceGenerator* nonce_generator,
149  RewriteDriver* driver,
150  bool using_candidate_key_detection,
151  BeaconMetadata* result);
152 
158 bool UpdateCandidateKeys(const StringSet& keys, CriticalKeys* proto,
159  bool clear_rebeacon_timestamp);
160 
163 inline bool IsBeaconDataAvailable(const CriticalKeys& proto) {
164  return (proto.valid_beacons_received() > 0);
165 }
166 
167 }
168 
169 #endif
CriticalKeysWriteFlags
Definition: critical_finder_support_util.h:113
const int64 kLowFreqBeaconMult
Definition: critical_finder_support_util.h:61
Nice name for lack of next two flags.
Definition: critical_finder_support_util.h:114
bool UpdateCandidateKeys(const StringSet &keys, CriticalKeys *proto, bool clear_rebeacon_timestamp)
bool IsBeaconDataAvailable(const CriticalKeys &proto)
Definition: critical_finder_support_util.h:163
const int64 kBeaconTimeoutIntervalMs
Definition: critical_finder_support_util.h:50
void UpdateCriticalKeys(bool require_prior_support, const StringSet &new_set, int support_value, CriticalKeys *critical_keys)
Definition: critical_finder_support_util.h:78
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
const int64 kNonceExpirationLimit
Definition: critical_finder_support_util.h:66
Definition: rewrite_driver.h:100
void PrepareForBeaconInsertionHelper(CriticalKeys *proto, NonceGenerator *nonce_generator, RewriteDriver *driver, bool using_candidate_key_detection, BeaconMetadata *result)
void WriteCriticalKeysToPropertyCache(const StringSet &new_keys, StringPiece nonce, int support_interval, CriticalKeysWriteFlags flags, StringPiece property_name, const PropertyCache *cache, const PropertyCache::Cohort *cohort, AbstractPropertyPage *page, MessageHandler *message_handler, Timer *timer)
const int64 kHighFreqBeaconCount
Definition: critical_finder_support_util.h:54
void GetCriticalKeysFromProto(int64 support_percentage, const CriticalKeys &critical_keys, StringSet *keys)
Definition: message_handler.h:39
Definition: nonce_generator.h:28
bool ValidateAndExpireNonce(int64 now_ms, StringPiece nonce, CriticalKeys *critical_keys)