本文整理汇总了C++中Prefix::ToUint32方法的典型用法代码示例。如果您正苦于以下问题:C++ Prefix::ToUint32方法的具体用法?C++ Prefix::ToUint32怎么用?C++ Prefix::ToUint32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prefix
的用法示例。
在下文中一共展示了Prefix::ToUint32方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLookupCache
nsresult
Classifier::ReadNoiseEntries(const Prefix& aPrefix,
const nsACString& aTableName,
PRInt32 aCount,
PrefixArray* aNoiseEntries)
{
LookupCache *cache = GetLookupCache(aTableName);
if (!cache) {
return NS_ERROR_FAILURE;
}
nsTArray<PRUint32> prefixes;
nsresult rv = cache->GetPrefixes(&prefixes);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 idx = prefixes.BinaryIndexOf(aPrefix.ToUint32());
if (idx == nsTArray<PRUint32>::NoIndex) {
NS_WARNING("Could not find prefix in PrefixSet during noise lookup");
return NS_ERROR_FAILURE;
}
idx -= idx % aCount;
for (PRInt32 i = 0; (i < aCount) && ((idx+i) < prefixes.Length()); i++) {
Prefix newPref;
newPref.FromUint32(prefixes[idx+i]);
aNoiseEntries->AppendElement(newPref);
}
return NS_OK;
}
示例2: GeneratePrefix
TEST(UrlClassifierCaching, NegativeCacheExpireV4)
{
_PrefixArray array = { GeneratePrefix(NEG_CACHE_EXPIRED_URL, 8) };
UniquePtr<LookupCacheV4> cache = SetupLookupCache<LookupCacheV4>(array);
FullHashResponseMap map;
Prefix prefix;
nsCOMPtr<nsICryptoHash> cryptoHash = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID);
prefix.FromPlaintext(NEG_CACHE_EXPIRED_URL);
CachedFullHashResponse* response = map.LookupOrAdd(prefix.ToUint32());
response->negativeCacheExpirySec = EXPIRED_TIME_SEC;
cache->AddFullHashResponseToCache(map);
// Ensure it is in cache in the first place.
EXPECT_EQ(cache->IsInCache(prefix.ToUint32()), true);
// It should be removed after calling Has API.
TestCache<LookupCacheV4>(NEG_CACHE_EXPIRED_URL, true, false, false, cache.get());
}
示例3:
static void
SetupCacheEntry(LookupCacheV4* aLookupCache,
const nsCString& aCompletion,
bool aNegExpired = false,
bool aPosExpired = false)
{
FullHashResponseMap map;
Prefix prefix;
prefix.FromPlaintext(aCompletion);
CachedFullHashResponse* response = map.LookupOrAdd(prefix.ToUint32());
response->negativeCacheExpirySec =
aNegExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC;
response->fullHashes.Put(GeneratePrefix(aCompletion, COMPLETE_SIZE),
aPosExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC);
aLookupCache->AddFullHashResponseToCache(map);
}