| 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 328bedcaf652852b7ae5b41836c4567cb66f11e4..c66eb6de3fe6534e072e407727cc1d806b6e9b9b 100644
|
| --- a/components/safe_browsing_db/v4_database.cc
|
| +++ b/components/safe_browsing_db/v4_database.cc
|
| @@ -2,10 +2,22 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <memory>
|
| +
|
| #include "components/safe_browsing_db/v4_database.h"
|
|
|
| namespace safe_browsing {
|
|
|
| +namespace {
|
| +
|
| +V4Store* CreateStore(
|
| + const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
| + const base::FilePath& store_path) {
|
| + return new V4Store(task_runner, store_path);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| // static
|
| V4DatabaseFactory* V4Database::factory_ = NULL;
|
|
|
| @@ -17,9 +29,21 @@ V4Database* V4Database::Create(
|
| const base::FilePath& base_path,
|
| ListInfoMap list_info_map) {
|
| DCHECK(db_task_runner->RunsTasksOnCurrentThread());
|
| + DCHECK(!base_path.empty());
|
| + DCHECK(!list_info_map.empty());
|
| +
|
| if (!factory_) {
|
| StoreMap store_map;
|
| - // TODO(vakh): Populate the store_map using list_suffix_map.
|
| +
|
| + for (const auto& list_info : list_info_map) {
|
| + UpdateListIdentifier update_list_identifier = list_info.first;
|
| + const base::FilePath::CharType suffix = list_info.second;
|
| +
|
| + const base::FilePath store_path =
|
| + base::FilePath(base_path.value() + suffix);
|
| + (*store_map)[update_list_identifier].reset(
|
| + CreateStore(db_task_runner, store_path));
|
| + }
|
| return new V4Database(db_task_runner, std::move(store_map));
|
| } else {
|
| return factory_->CreateV4Database(db_task_runner, base_path, list_info_map);
|
| @@ -28,15 +52,20 @@ V4Database* V4Database::Create(
|
|
|
| V4Database::V4Database(
|
| const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
|
| - StoreMap store_map) {
|
| + StoreMap store_map)
|
| + : db_task_runner_(db_task_runner), store_map_(std::move(store_map)) {
|
| // TODO(vakh): Implement skeleton
|
| }
|
|
|
| V4Database::~V4Database() {}
|
|
|
| bool V4Database::ResetDatabase() {
|
| - // TODO(vakh): Delete the stores. Delete the backing files.
|
| - return true;
|
| + bool reset_success = true;
|
| + for (const auto& store_id_and_store : *store_map_) {
|
| + bool store_reset_success = store_id_and_store.second->Reset();
|
| + reset_success = reset_success && store_reset_success;
|
| + }
|
| + return reset_success;
|
| }
|
|
|
| } // namespace safe_browsing
|
|
|