Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: components/safe_browsing_db/v4_database.cc

Issue 1983603002: Revert of Initialize and reset V4LocalDBManager. Instantiate V4Stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v4_01_db_realz
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/safe_browsing_db/v4_database.h ('k') | components/safe_browsing_db/v4_local_database_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5c7246e38999f89d0c129713bb6c06e146e12e5e..328bedcaf652852b7ae5b41836c4567cb66f11e4 100644
--- a/components/safe_browsing_db/v4_database.cc
+++ b/components/safe_browsing_db/v4_database.cc
@@ -2,96 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <memory>
-
-#include "base/callback.h"
-#include "base/message_loop/message_loop.h"
#include "components/safe_browsing_db/v4_database.h"
-#include "content/public/browser/browser_thread.h"
-
-using content::BrowserThread;
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;
// static
-void V4Database::Create(
+// Factory method, should be called on the Safe Browsing sequenced task runner,
+// which is also passed to the function as |db_task_runner|.
+V4Database* V4Database::Create(
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
const base::FilePath& base_path,
- ListInfoMap list_info_map,
- NewDatabaseReadyCallback callback) {
- const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner =
- base::MessageLoop::current()->task_runner();
- db_task_runner->PostTask(
- FROM_HERE,
- base::Bind(&V4Database::CreateOnTaskRunner, db_task_runner, base_path,
- list_info_map, callback_task_runner, callback));
-}
-
-// static
-void V4Database::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) {
+ ListInfoMap list_info_map) {
DCHECK(db_task_runner->RunsTasksOnCurrentThread());
- DCHECK(!base_path.empty());
-
- std::unique_ptr<V4Database> v4_database;
if (!factory_) {
StoreMap store_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));
- }
-
- v4_database.reset(new V4Database(db_task_runner, std::move(store_map)));
+ // TODO(vakh): Populate the store_map using list_suffix_map.
+ return new V4Database(db_task_runner, std::move(store_map));
} else {
- v4_database.reset(
- factory_->CreateV4Database(db_task_runner, base_path, list_info_map));
+ return factory_->CreateV4Database(db_task_runner, base_path, list_info_map);
}
- callback_task_runner->PostTask(
- FROM_HERE, base::Bind(callback, base::Passed(&v4_database)));
}
V4Database::V4Database(
const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
- StoreMap store_map)
- : db_task_runner_(db_task_runner), store_map_(std::move(store_map)) {
- DCHECK(db_task_runner->RunsTasksOnCurrentThread());
+ StoreMap store_map) {
// TODO(vakh): Implement skeleton
}
V4Database::~V4Database() {}
bool V4Database::ResetDatabase() {
- DCHECK(db_task_runner_->RunsTasksOnCurrentThread());
- bool reset_success = true;
- for (const auto& store_id_and_store : *store_map_) {
- if (!store_id_and_store.second->Reset()) {
- reset_success = false;
- }
- }
- return reset_success;
+ // TODO(vakh): Delete the stores. Delete the backing files.
+ return true;
}
} // namespace safe_browsing
« no previous file with comments | « components/safe_browsing_db/v4_database.h ('k') | components/safe_browsing_db/v4_local_database_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698