本文整理汇总了C++中Prefix::FromPlaintext方法的典型用法代码示例。如果您正苦于以下问题:C++ Prefix::FromPlaintext方法的具体用法?C++ Prefix::FromPlaintext怎么用?C++ Prefix::FromPlaintext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prefix
的用法示例。
在下文中一共展示了Prefix::FromPlaintext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
SetupCacheEntry(LookupCacheV2* aLookupCache,
const nsCString& aCompletion,
bool aNegExpired = false,
bool aPosExpired = false)
{
AddCompleteArray completes;
AddCompleteArray emptyCompletes;
MissPrefixArray misses;
MissPrefixArray emptyMisses;
AddComplete* add = completes.AppendElement(fallible);
add->complete.FromPlaintext(aCompletion);
Prefix* prefix = misses.AppendElement(fallible);
prefix->FromPlaintext(aCompletion);
// Setup positive cache first otherwise negative cache expiry will be
// overwritten.
int64_t posExpirySec = aPosExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC;
aLookupCache->AddGethashResultToCache(completes, emptyMisses, posExpirySec);
int64_t negExpirySec = aNegExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC;
aLookupCache->AddGethashResultToCache(emptyCompletes, misses, negExpirySec);
}
示例2: GeneratePrefix
// This testcase check if an cache entry whose negative cache time is expired
// and it doesn't have any postive cache entries in it, it should be removed
// from cache after calling |Has|.
TEST(UrlClassifierCaching, NegativeCacheExpireV2)
{
_PrefixArray array = { GeneratePrefix(NEG_CACHE_EXPIRED_URL, 8) };
UniquePtr<LookupCacheV2> cache = SetupLookupCache<LookupCacheV2>(array);
nsCOMPtr<nsICryptoHash> cryptoHash = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID);
MissPrefixArray misses;
Prefix* prefix = misses.AppendElement(fallible);
prefix->FromPlaintext(NEG_CACHE_EXPIRED_URL);
AddCompleteArray dummy;
cache->AddGethashResultToCache(dummy, misses, EXPIRED_TIME_SEC);
// 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<LookupCacheV2>(NEG_CACHE_EXPIRED_URL, true, false, false, cache.get());
}