当前位置: 首页>>代码示例>>C++>>正文


C++ Prefix::ToUint32方法代码示例

本文整理汇总了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;
}
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:32,代码来源:Classifier.cpp

示例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());
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:21,代码来源:TestCaching.cpp

示例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);
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:20,代码来源:TestCaching.cpp


注:本文中的Prefix::ToUint32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。