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 509939e68be6366928a21ca4071958d50fb574b7..d8a159197788bdf201ef0e898ff81c26c33d1537 100644 |
--- a/components/safe_browsing_db/v4_database.h |
+++ b/components/safe_browsing_db/v4_database.h |
@@ -8,6 +8,7 @@ |
#include "base/files/file_path.h" |
#include "base/memory/ref_counted.h" |
#include "base/sequenced_task_runner.h" |
+#include "base/single_thread_task_runner.h" |
#include "components/safe_browsing_db/v4_protocol_manager_util.h" |
#include "components/safe_browsing_db/v4_store.h" |
@@ -15,6 +16,9 @@ namespace safe_browsing { |
class V4Database; |
+typedef base::Callback<void(std::unique_ptr<V4Database>)> |
+ NewDatabaseReadyCallback; |
+ |
typedef const base::hash_map<UpdateListIdentifier, |
const base::FilePath::CharType> |
ListInfoMap; |
@@ -43,18 +47,15 @@ class V4DatabaseFactory { |
// The V4Database serves as a single place to manage all the V4Stores. |
class V4Database { |
public: |
- // Factory method for obtaining a V4Database implementation. |
- // It is not thread safe. |
- // The availability of each list is controlled by the one flag on this |
- // method. |
- static V4Database* Create( |
+ // Factory method to create a V4Database. It creates the database on the |
+ // provided |db_task_runner|. When the database creation is complete, it calls |
+ // the NewDatabaseReadyCallback on the same thread as it was called. |
+ static void Create( |
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
const base::FilePath& base_path, |
- ListInfoMap list_info_map); |
+ ListInfoMap list_info_map, |
+ NewDatabaseReadyCallback callback); |
- V4Database( |
- const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
- StoreMap store_map); |
virtual ~V4Database(); |
// Deletes the current database and creates a new one. |
@@ -66,7 +67,25 @@ class V4Database { |
factory_ = factory; |
} |
+ protected: |
+ V4Database(const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
+ StoreMap store_map); |
+ |
private: |
+ // Factory method to create a V4Database. When the database creation is |
+ // complete, it calls the NewDatabaseReadyCallback on |callback_task_runner|. |
+ static void CreateOnTaskRunner( |
+ const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
+ const base::FilePath& base_path, |
+ ListInfoMap list_info_map, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, |
+ NewDatabaseReadyCallback callback); |
+ |
+ const scoped_refptr<base::SequencedTaskRunner> db_task_runner_; |
+ |
+ // Map of UpdateListIdentifier to the V4Store. |
+ StoreMap store_map_; |
+ |
// The factory that controls the creation of V4Database objects. |
// This is used *only* by tests. |
static V4DatabaseFactory* factory_; |