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

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: shess@ feedback 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..be7fdc01939267e0ed37ba43c8eba8cc09a62b64 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,14 @@ 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 |db_ready_for_updates_callback|
+ // callback with the stores to reset, if any, and then we can schedule the
+ // database updates.
+ DatabaseReadyForUpdatesCallback db_ready_for_updates_callback =
+ base::Bind(&V4LocalDatabaseManager::DatabaseReadyForUpdates,
+ base::Unretained(this));
+ v4_database_->VerifyChecksum(db_ready_for_updates_callback);
Nathan Parker 2016/10/07 23:24:28 nit: This says "db ready for updates" four times..
vakh (use Gerrit instead) 2016/10/10 17:42:33 Done.
ProcessQueuedChecks();
} else {
@@ -292,6 +297,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. Start fetching them now.
Nathan Parker 2016/10/07 23:24:28 s/Start fetching/Schedule
vakh (use Gerrit instead) 2016/10/10 17:42:33 Done.
+ v4_update_protocol_manager_->ScheduleNextUpdate(
+ v4_database_->GetStoreStateMap());
+ }
+}
+
void V4LocalDatabaseManager::DatabaseUpdated() {
if (enabled_) {
v4_update_protocol_manager_->ScheduleNextUpdate(
@@ -456,7 +472,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