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

Unified Diff: components/safe_browsing_db/v4_store.h

Issue 2154973002: Reland: PVer4: Keep track of the smallest hashes not their sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't increment the iterator past the end. Check first. Created 4 years, 5 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
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_store.cc » ('j') | components/safe_browsing_db/v4_store.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_store.h
diff --git a/components/safe_browsing_db/v4_store.h b/components/safe_browsing_db/v4_store.h
index c2118b4ae62f3502a00db5afac363cdb4a3eed80..c4bf355f7e5e3f784483b96d636c87d093165daa 100644
--- a/components/safe_browsing_db/v4_store.h
+++ b/components/safe_browsing_db/v4_store.h
@@ -32,10 +32,11 @@ typedef std::string HashPrefixes;
// For instance: {4: ["abcd", "bcde", "cdef", "gggg"], 5: ["fffff"]}
typedef base::hash_map<PrefixSize, HashPrefixes> HashPrefixMap;
-// Stores the index of the last element merged from the HashPrefixMap for a
-// given prefix size. For instance: {4:3, 5:1} means that we have already merged
+// Stores the iterator to the last element merged from the HashPrefixMap for a
+// given prefix size.
+// For instance: {4:iter(3), 5:iter(1)} means that we have already merged
// 3 hash prefixes of length 4, and 1 hash prefix of length 5.
-typedef base::hash_map<PrefixSize, size_t> CounterMap;
+typedef base::hash_map<PrefixSize, HashPrefixes::const_iterator> IteratorMap;
// Enumerate different failure events while parsing the file read from disk for
// histogramming purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES.
@@ -185,9 +186,8 @@ class V4Store {
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestAddUnlumpedHashes);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestAddUnlumpedHashesWithEmptyString);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest,
- TestGetNextSmallestPrefixSizeWithEmptyPrefixMap);
- FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextSmallestPrefixSize);
- FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextUnmergedPrefix);
+ TestGetNextSmallestUnmergedPrefixWithEmptyPrefixMap);
+ FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextSmallestUnmergedPrefix);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesWithSameSizesInEachMap);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest,
TestMergeUpdatesWithDifferentSizesInEachMap);
@@ -208,25 +208,19 @@ class V4Store {
const std::string& raw_hashes,
HashPrefixMap* additions_map);
- // Get the size of the next unmerged hash prefix in dictionary order from
- // |hash_prefix_map|. |counter_map| is used to determine which hash prefixes
+ // Get the next unmerged hash prefix in dictionary order from
+ // |hash_prefix_map|. |iterator_map| is used to determine which hash prefixes
// have been merged already. Returns true if there are any unmerged hash
// prefixes in the list.
- static bool GetNextSmallestPrefixSize(const HashPrefixMap& hash_prefix_map,
- const CounterMap& counter_map,
- PrefixSize* smallest_prefix_size);
-
- // Returns the next hash prefix of length |prefix_size| from |hash_prefix_map|
- // that hasn't been merged already. |counter_map| is used to determine the
- // index of the next prefix of size |prefix_size| to merge.
- static HashPrefix GetNextUnmergedPrefixForSize(
- PrefixSize prefix_size,
+ static bool GetNextSmallestUnmergedPrefix(
const HashPrefixMap& hash_prefix_map,
- const CounterMap& counter_map);
+ const IteratorMap& iterator_map,
+ HashPrefix* smallest_hash_prefix);
- // Sets a value of 0 in |counter_map| for all keys in |hash_prefix_map|.
- static void InitializeCounterMap(const HashPrefixMap& hash_prefix_map,
- CounterMap* counter_map);
+ // For each key in |hash_prefix_map|, sets the iterator at that key
+ // |iterator_map| to hash_prefix_map[key].begin().
+ static void InitializeIteratorMap(const HashPrefixMap& hash_prefix_map,
+ IteratorMap* iterator_map);
// Reserve the appropriate string size so that the string size of the merged
// list is exact. This ignores the space that would otherwise be released by
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_store.cc » ('j') | components/safe_browsing_db/v4_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698