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

Unified Diff: components/safe_browsing_db/v4_local_database_manager.cc

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
Index: components/safe_browsing_db/v4_local_database_manager.cc
diff --git a/components/safe_browsing_db/v4_local_database_manager.cc b/components/safe_browsing_db/v4_local_database_manager.cc
index 28320252fec77167878326768d915c7ef53f9ae8..e489946da80f5a59bf471d97b3392b0571b4b531 100644
--- a/components/safe_browsing_db/v4_local_database_manager.cc
+++ b/components/safe_browsing_db/v4_local_database_manager.cc
@@ -272,7 +272,7 @@ void V4LocalDatabaseManager::StopOnIOThread(bool shutdown) {
// End: SafeBrowsingDatabaseManager implementation
//
-void V4LocalDatabaseManager::DatabaseReady(
+void V4LocalDatabaseManager::DatabaseReadyForChecks(
std::unique_ptr<V4Database> v4_database) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -281,9 +281,13 @@ void V4LocalDatabaseManager::DatabaseReady(
if (enabled_) {
v4_database_ = std::move(v4_database);
- // The database is in place. Start fetching updates now.
- v4_update_protocol_manager_->ScheduleNextUpdate(
- v4_database_->GetStoreStateMap());
+ // The consistency of the stores read from the disk needs to verified. Post
+ // that task on the task runner. It calls |DatabaseReadyForUpdates|
+ // callback with the stores to reset, if any, and then we can schedule the
+ // database updates.
+ v4_database_->VerifyChecksum(
+ base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates,
+ base::Unretained(this)));
ProcessQueuedChecks();
} else {
@@ -292,6 +296,17 @@ void V4LocalDatabaseManager::DatabaseReady(
}
}
+void V4LocalDatabaseManager::DatabaseReadyForUpdates(
+ const std::vector<ListIdentifier>& stores_to_reset) {
+ if (enabled_) {
+ v4_database_->ResetStores(stores_to_reset);
+
+ // The database is ready to process updates. Schedule them now.
+ v4_update_protocol_manager_->ScheduleNextUpdate(
+ v4_database_->GetStoreStateMap());
+ }
+}
+
void V4LocalDatabaseManager::DatabaseUpdated() {
if (enabled_) {
v4_update_protocol_manager_->ScheduleNextUpdate(
@@ -456,7 +471,7 @@ void V4LocalDatabaseManager::SetupDatabase() {
// operation. Instead, do that on the task_runner and when the new database
// has been created, swap it out on the IO thread.
NewDatabaseReadyCallback db_ready_callback = base::Bind(
- &V4LocalDatabaseManager::DatabaseReady, base::Unretained(this));
+ &V4LocalDatabaseManager::DatabaseReadyForChecks, base::Unretained(this));
V4Database::Create(task_runner_, base_path_, list_infos_, db_ready_callback);
}

Powered by Google App Engine
This is Rietveld 408576698