Page Speed Optimization Libraries  1.7.30.3
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 class RewriteDriver;
00054 
00055 enum BeaconStatus {
00056   kDoNotBeacon,
00057   kBeaconNoNonce,
00058   kBeaconWithNonce
00059 };
00060 
00061 struct BeaconMetadata {
00062   BeaconMetadata() : status(kDoNotBeacon) { }
00063   BeaconStatus status;
00064   GoogleString nonce;
00065 };
00066 
00072 bool ValidateAndExpireNonce(int64 now_ms, StringPiece nonce,
00073                             CriticalKeys* critical_keys);
00074 
00081 void GetCriticalKeysFromProto(int64 support_percentage,
00082                               const CriticalKeys& critical_keys,
00083                               StringSet* keys);
00084 
00090 void UpdateCriticalKeys(bool require_prior_support,
00091                         const StringSet& new_set, int support_value,
00092                         CriticalKeys* critical_keys);
00093 
00101 void WriteCriticalKeysToPropertyCache(
00102     const StringSet& new_keys, StringPiece nonce, int support_interval,
00103     bool should_replace_prior_result, bool require_prior_support,
00104     StringPiece property_name, const PropertyCache* cache,
00105     const PropertyCache::Cohort* cohort, AbstractPropertyPage* page,
00106     MessageHandler* message_handler, Timer* timer);
00107 
00116 void PrepareForBeaconInsertionHelper(
00117     const StringSet& keys, CriticalKeys* proto, int support_interval,
00118     NonceGenerator* nonce_generator, RewriteDriver* driver,
00119     BeaconMetadata* result);
00120 
00121 }  
00122 
00123 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_CRITICAL_FINDER_SUPPORT_UTIL_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines