Page Speed Optimization Libraries  1.7.30.1
net/instaweb/rewriter/public/critical_finder_support_util.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2013 Google Inc.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http:///www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00034 
00035 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_FINDER_SUPPORT_UTIL_H_
00036 #define NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_FINDER_SUPPORT_UTIL_H_
00037 
00038 #include "net/instaweb/util/public/basictypes.h"
00039 #include "net/instaweb/util/public/property_cache.h"
00040 #include "net/instaweb/util/public/string.h"
00041 #include "net/instaweb/util/public/string_util.h"
00042 #include "net/instaweb/util/public/timer.h"
00043 
00044 namespace net_instaweb {
00045 
00047 const int64 kMinBeaconIntervalMs = 5 * Timer::kSecondMs;
00048 const int64 kBeaconTimeoutIntervalMs = Timer::kMinuteMs;
00049 
00050 class CriticalKeys;
00051 class MessageHandler;
00052 class NonceGenerator;
00053 
00054 enum BeaconStatus {
00055   kDoNotBeacon,
00056   kBeaconNoNonce,
00057   kBeaconWithNonce
00058 };
00059 
00060 struct BeaconMetadata {
00061   BeaconMetadata() : status(kDoNotBeacon) { }
00062   BeaconStatus status;
00063   GoogleString nonce;
00064 };
00065 
00071 bool ValidateAndExpireNonce(int64 now_ms, StringPiece nonce,
00072                             CriticalKeys* critical_keys);
00073 
00080 void GetCriticalKeysFromProto(int64 support_percentage,
00081                               const CriticalKeys& critical_keys,
00082                               StringSet* keys);
00083 
00089 void UpdateCriticalKeys(bool require_prior_support,
00090                         const StringSet& new_set, int support_value,
00091                         CriticalKeys* critical_keys);
00092 
00100 void WriteCriticalKeysToPropertyCache(
00101     const StringSet& new_keys, StringPiece nonce, int support_interval,
00102     bool should_replace_prior_result, bool require_prior_support,
00103     StringPiece property_name, const PropertyCache* cache,
00104     const PropertyCache::Cohort* cohort, AbstractPropertyPage* page,
00105     MessageHandler* message_handler, Timer* timer);
00106 
00115 void PrepareForBeaconInsertion(
00116     const StringSet& keys, CriticalKeys* proto, int support_interval,
00117     NonceGenerator* nonce_generator, Timer* timer,
00118     BeaconMetadata* result);
00119 
00120 }  
00121 
00122 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_FINDER_SUPPORT_UTIL_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines