| Index: components/safe_browsing_db/v4_database.cc
|
| diff --git a/components/safe_browsing_db/v4_database.cc b/components/safe_browsing_db/v4_database.cc
|
| index 5a9742067829bb810584b6c896108cfdb1a26113..8b20a88b3444cf5526903604da78e1f487b3f7b6 100644
|
| --- a/components/safe_browsing_db/v4_database.cc
|
| +++ b/components/safe_browsing_db/v4_database.cc
|
| @@ -25,18 +25,7 @@
|
| } // namespace
|
|
|
| // static
|
| -std::unique_ptr<V4DatabaseFactory> V4Database::db_factory_;
|
| -
|
| -// static
|
| -std::unique_ptr<V4StoreFactory> V4Database::store_factory_;
|
| -
|
| -std::unique_ptr<V4Database> V4DatabaseFactory::Create(
|
| - const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
|
| - std::unique_ptr<StoreMap> store_map) {
|
| - // Not using MakeUnique since the constructor of V4Database is protected.
|
| - return std::unique_ptr<V4Database>(
|
| - new V4Database(db_task_runner, std::move(store_map)));
|
| -}
|
| +V4StoreFactory* V4Database::factory_ = NULL;
|
|
|
| // static
|
| void V4Database::Create(
|
| @@ -65,8 +54,9 @@
|
| const TimeTicks create_start_time) {
|
| DCHECK(db_task_runner->RunsTasksOnCurrentThread());
|
|
|
| - if (!store_factory_) {
|
| - store_factory_.reset(new V4StoreFactory());
|
| + if (!factory_) {
|
| + factory_ = new V4StoreFactory();
|
| + ANNOTATE_LEAKING_OBJECT_PTR(factory_);
|
| }
|
|
|
| if (!base::CreateDirectory(base_path)) {
|
| @@ -82,14 +72,10 @@
|
|
|
| const base::FilePath store_path = base_path.AppendASCII(it.filename());
|
| (*store_map)[it.list_id()].reset(
|
| - store_factory_->CreateV4Store(db_task_runner, store_path));
|
| - }
|
| -
|
| - if (!db_factory_) {
|
| - db_factory_.reset(new V4DatabaseFactory());
|
| + factory_->CreateV4Store(db_task_runner, store_path));
|
| }
|
| std::unique_ptr<V4Database> v4_database(
|
| - db_factory_->Create(db_task_runner, std::move(store_map)));
|
| + new V4Database(db_task_runner, std::move(store_map)));
|
|
|
| // Database is done loading, pass it to the new_db_callback on the caller's
|
| // thread. This would unblock resource loads.
|
| @@ -103,8 +89,8 @@
|
| V4Database::V4Database(
|
| const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
|
| std::unique_ptr<StoreMap> store_map)
|
| - : store_map_(std::move(store_map)),
|
| - db_task_runner_(db_task_runner),
|
| + : db_task_runner_(db_task_runner),
|
| + store_map_(std::move(store_map)),
|
| pending_store_updates_(0),
|
| weak_factory_on_io_(this) {
|
| DCHECK(db_task_runner->RunsTasksOnCurrentThread());
|
|
|