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. |