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

Unified Diff: components/safe_browsing_db/v4_database.h

Issue 2384893002: PVer4: Test checksum on startup outside the hotpath of DB load (Closed)
Patch Set: Verify that the checksum check happens async 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_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_database.h
diff --git a/components/safe_browsing_db/v4_database.h b/components/safe_browsing_db/v4_database.h
index bddba598850d4b5750b1274981242f1112a5a1be..9c2e40541efb72fb0f25c5265c4eb43562717200 100644
--- a/components/safe_browsing_db/v4_database.h
+++ b/components/safe_browsing_db/v4_database.h
@@ -17,9 +17,17 @@ namespace safe_browsing {
class V4Database;
+// Scheduled when the database has been read from disk and is ready to process
+// resource reputation requests.
typedef base::Callback<void(std::unique_ptr<V4Database>)>
NewDatabaseReadyCallback;
+// Scheduled when the checksum for all the stores in the database has been
+// verified to match the expected value. Stores for which the checksum did not
+// match are passed as the argument and need to be reset.
+typedef base::Callback<void(const std::vector<ListIdentifier>&)>
+ DatabaseReadyForUpdatesCallback;
+
// This callback is scheduled once the database has finished processing the
// update requests for all stores and is ready to process the next set of update
// requests.
@@ -116,8 +124,17 @@ class V4Database {
const StoresToCheck& stores_to_check,
StoreAndHashPrefixes* matched_store_and_full_hashes);
- // Deletes the current database and creates a new one.
- virtual bool ResetDatabase();
+ // Resets the stores in |stores_to_reset| to an empty state. This is done if
+ // the checksum doesn't match the expected value.
+ void ResetStores(const std::vector<ListIdentifier>& stores_to_reset);
+
+ // Schedules verification of the checksum of each store read from disk on task
+ // runner. If the checksum doesn't match, that store is passed to the
+ // |db_ready_for_updates_callback|. At the end,
+ // |db_ready_for_updates_callback| is scheduled (on the same thread as it was
+ // called) to indicate that the database updates can now be scheduled.
+ void VerifyChecksum(
+ DatabaseReadyForUpdatesCallback db_ready_for_updates_callback);
protected:
V4Database(const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
@@ -155,6 +172,11 @@ class V4Database {
void UpdatedStoreReady(ListIdentifier identifier,
std::unique_ptr<V4Store> store);
+ // See |VerifyChecksum|.
+ void VerifyChecksumOnTaskRunner(
+ const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
+ DatabaseReadyForUpdatesCallback db_ready_for_updates_callback);
+
const scoped_refptr<base::SequencedTaskRunner> db_task_runner_;
// Map of ListIdentifier to the V4Store.
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698