Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1702)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_database_bloom.cc

Issue 67243: Reduce the false positive rate for SafeBrowsing gethash requests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_database_bloom.cc (revision 13914)
+++ chrome/browser/safe_browsing/safe_browsing_database_bloom.cc (working copy)
@@ -30,9 +30,6 @@
// downloading the data and then keep having to rebuild it.
static const int kBloomFilterMinSize = 250000;
-// How many bits to use per item. See the design doc for more information.
-static const int kBloomFilterSizeRatio = 13;
-
// When we awake from a low power state, we try to avoid doing expensive disk
// operations for a few minutes to let the system page itself in and settle
// down.
@@ -1065,8 +1062,11 @@
return false;
}
+ // Determine the size of the new bloom filter. We will cap the maximum size at
+ // 2 MB to prevent an error from consuming large amounts of memory.
int number_of_keys = std::max(add_count_, kBloomFilterMinSize);
- int filter_size = number_of_keys * kBloomFilterSizeRatio;
+ int filter_size = std::min(number_of_keys * kBloomFilterSizeRatio,
+ 2 * 1024 * 1024 * 8);
BloomFilter* new_filter = new BloomFilter(filter_size);
SBPair* add = adds;
int new_count = 0;
@@ -1357,6 +1357,7 @@
UMA_HISTOGRAM_LONG_TIMES("SB2.BuildFilter", bloom_gen);
UMA_HISTOGRAM_COUNTS("SB2.AddPrefixes", add_count_);
UMA_HISTOGRAM_COUNTS("SB2.SubPrefixes", subs);
+ UMA_HISTOGRAM_COUNTS("SB2.FilterSize", filter->size());
int64 size_64;
if (file_util::GetFileSize(filename_, &size_64))
UMA_HISTOGRAM_COUNTS("SB2.DatabaseBytes", static_cast<int>(size_64));

Powered by Google App Engine
This is Rietveld 408576698