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

Unified Diff: components/safe_browsing_db/v4_store.h

Issue 2384893002: PVer4: Test checksum on startup outside the hotpath of DB load (Closed)
Patch Set: Remove all histogram related changes. That would be a separate CL 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
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 f0172808c8f92d8b0df83b25a174801190c2ac8a..ed86f36dd181b6652c834e28e6aead5a84cbd069 100644
--- a/components/safe_browsing_db/v4_store.h
+++ b/components/safe_browsing_db/v4_store.h
@@ -180,8 +180,8 @@ class V4Store {
// of the hash prefixes.
void Initialize();
- // Reset internal state and delete the backing file.
- virtual bool Reset();
+ // Reset internal state.
+ void Reset();
private:
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestReadFromEmptyFile);
@@ -246,6 +246,7 @@ class V4Store {
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestAdditionsWithRiceEncodingSucceeds);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestRemovalsWithRiceEncodingSucceeds);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesFailsChecksum);
+ FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestChecksumErrorOnStartup);
friend class V4StoreTest;
// If |prefix_size| is within expected range, and |raw_hashes_length| is a
@@ -293,8 +294,9 @@ class V4Store {
// Merges the prefix map from the old store (|old_hash_prefix_map|) and the
// update (additions_map) to populate the prefix map for the current store.
// 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 lexographically
- // sorted order, must match |expected_checksum| (if it's not empty).
+ // 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<
@@ -335,12 +337,21 @@ class V4Store {
// for the failure or reports success.
StoreReadResult ReadFromDisk();
+ // Resets the state of the store on the IO thread.
+ void ResetOnIOThread();
+
// Updates the |additions_map| with the additions received in the partial
// update from the server.
ApplyUpdateResult UpdateHashPrefixMapFromAdditions(
const ::google::protobuf::RepeatedPtrField<ThreatEntrySet>& additions,
HashPrefixMap* additions_map);
+ // Scheduled when reading the store file from disk on startup. When run, it
+ // ensures that the checksum of the hash prefixes in lexicographical sorted
+ // order matches the expected value. If not, it clears out the contents of
+ // the store.
+ void VerifyChecksumDelayed(const std::string& expected_checksum);
+
// Writes the FULL_UPDATE |response| to disk as a V4StoreFileFormat proto.
StoreWriteResult WriteToDisk(
std::unique_ptr<ListUpdateResponse> response) const;

Powered by Google App Engine
This is Rietveld 408576698