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

Unified Diff: components/safe_browsing_db/v4_store.h

Issue 2406373003: Small: Delay checksum only on ReadFromDisk, not in FullUpdate cases (Closed)
Patch Set: Created 4 years, 2 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 1939aea4c1a41c37994f372213e8ce34d2ad0584..b10a3c373dbef8f65827c4504ce3dde9bc13630c 100644
--- a/components/safe_browsing_db/v4_store.h
+++ b/components/safe_browsing_db/v4_store.h
@@ -256,6 +256,7 @@ class V4Store {
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesFailsChecksum);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestChecksumErrorOnStartup);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, WriteToDiskFails);
+ FRIEND_TEST_ALL_PREFIXES(V4StoreTest, FullUpdateFailsChecksumSynchronously);
friend class V4StoreTest;
// If |prefix_size| is within expected range, and |raw_hashes_length| is a
@@ -305,12 +306,14 @@ class V4Store {
// The indices in the |raw_removals| list, which may be NULL, are not merged.
// The SHA256 checksum of the final list of hash prefixes, in
// lexicographically sorted order, must match |expected_checksum| (if it's not
- // empty).
- ApplyUpdateResult MergeUpdate(const HashPrefixMap& old_hash_prefix_map,
- const HashPrefixMap& additions_map,
- const ::google::protobuf::RepeatedField<
- ::google::protobuf::int32>* raw_removals,
- const std::string& expected_checksum);
+ // empty). Delays the checksum check if |delay_checksum_check| is true.
+ ApplyUpdateResult MergeUpdate(
+ const HashPrefixMap& old_hash_prefix_map,
+ const HashPrefixMap& additions_map,
+ const ::google::protobuf::RepeatedField<::google::protobuf::int32>*
+ raw_removals,
+ const std::string& expected_checksum,
+ bool delay_checksum_check);
// Processes the FULL_UPDATE |response| from the server, and writes the
// merged V4Store to disk. If processing the |response| succeeds, it returns
@@ -322,9 +325,11 @@ class V4Store {
// Processes a FULL_UPDATE |response| and updates the V4Store. If processing
// the |response| succeeds, it returns APPLY_UPDATE_SUCCESS.
// This method is called when we receive a FULL_UPDATE from the server, and
- // when we read a store file from disk on startup.
+ // when we read a store file from disk on startup. Delays the checksum check
+ // if |delay_checksum_check| is true.
ApplyUpdateResult ProcessFullUpdate(
- const std::unique_ptr<ListUpdateResponse>& response);
+ const std::unique_ptr<ListUpdateResponse>& response,
+ bool delay_checksum_check);
// Merges the hash prefixes in |hash_prefix_map_old| and |response|, updates
// the |hash_prefix_map_| and |state_| in the V4Store, and writes the merged
@@ -337,10 +342,12 @@ class V4Store {
// Merges the hash prefixes in |hash_prefix_map_old| and |response|, and
// updates the |hash_prefix_map_| and |state_| in the V4Store. If processing
- // succeeds, it returns APPLY_UPDATE_SUCCESS.
+ // succeeds, it returns APPLY_UPDATE_SUCCESS. Delays the checksum check if
+ // |delay_checksum_check| is true.
ApplyUpdateResult ProcessUpdate(
const HashPrefixMap& hash_prefix_map_old,
- const std::unique_ptr<ListUpdateResponse>& response);
+ const std::unique_ptr<ListUpdateResponse>& response,
+ bool delay_checksum_check);
// Reads the state of the store from the file on disk and returns the reason
// for the failure or reports success.
« 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