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 cc07d4e308a8be28944a2ba2e84e0d7eaae50fde..15fa61fe0e7d8b04f2ff5b5dd85ea517fc78862d 100644 |
--- a/components/safe_browsing_db/v4_database.h |
+++ b/components/safe_browsing_db/v4_database.h |
@@ -78,10 +78,9 @@ typedef std::vector<ListInfo> ListInfos; |
class V4DatabaseFactory { |
public: |
virtual ~V4DatabaseFactory() {} |
- virtual V4Database* CreateV4Database( |
+ virtual std::unique_ptr<V4Database> Create( |
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
- const base::FilePath& base_dir_path, |
- const ListInfos& list_infos) = 0; |
+ std::unique_ptr<StoreMap> store_map); |
}; |
// The on-disk databases are shared among all profiles, as it doesn't contain |
@@ -101,12 +100,18 @@ class V4Database { |
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
const base::FilePath& base_path, |
const ListInfos& list_infos, |
- NewDatabaseReadyCallback callback); |
+ NewDatabaseReadyCallback new_db_callback); |
// Destroys the provided v4_database on its task_runner since this may be a |
// long operation. |
static void Destroy(std::unique_ptr<V4Database> v4_database); |
+ // Makes the passed |factory| the factory used to instantiate a V4Database. |
+ // Only for tests. |
+ static void RegisterFactory(std::unique_ptr<V4DatabaseFactory> factory) { |
+ db_factory_ = std::move(factory); |
+ } |
+ |
virtual ~V4Database(); |
// Updates the stores with the response received from the SafeBrowsing service |
@@ -153,6 +158,7 @@ class V4Database { |
std::unique_ptr<StoreMap> store_map); |
private: |
+ friend class V4DatabaseFactory; |
friend class V4DatabaseTest; |
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestSetupDatabaseWithFakeStores); |
FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, |
@@ -165,8 +171,9 @@ class V4Database { |
// Makes the passed |factory| the factory used to instantiate a V4Store. Only |
// for tests. |
- static void RegisterStoreFactoryForTest(V4StoreFactory* factory) { |
- factory_ = factory; |
+ static void RegisterStoreFactoryForTest( |
+ std::unique_ptr<V4StoreFactory> factory) { |
+ store_factory_ = std::move(factory); |
} |
// Factory method to create a V4Database. When the database creation is |
@@ -190,15 +197,20 @@ class V4Database { |
const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, |
DatabaseReadyForUpdatesCallback db_ready_for_updates_callback); |
- const scoped_refptr<base::SequencedTaskRunner> db_task_runner_; |
- |
+ protected: |
// Map of ListIdentifier to the V4Store. |
const std::unique_ptr<StoreMap> store_map_; |
+ private: |
+ const scoped_refptr<base::SequencedTaskRunner> db_task_runner_; |
+ |
DatabaseUpdatedCallback db_updated_callback_; |
+ // The factory that controls the creation of the V4Database object. |
+ static std::unique_ptr<V4DatabaseFactory> db_factory_; |
Nathan Parker
2017/02/10 00:52:37
(I'm not sure if this ever gets deleted... but I t
vakh (use Gerrit instead)
2017/02/10 01:08:15
Acknowledged.
|
+ |
// The factory that controls the creation of V4Store objects. |
- static V4StoreFactory* factory_; |
+ static std::unique_ptr<V4StoreFactory> store_factory_; |
// The number of stores for which the update request is pending. When this |
// goes down to 0, that indicates that the database has updated all the stores |