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

Unified Diff: components/safe_browsing_db/v4_local_database_manager.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_local_database_manager.h ('k') | components/safe_browsing_db/v4_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_local_database_manager.cc
diff --git a/components/safe_browsing_db/v4_local_database_manager.cc b/components/safe_browsing_db/v4_local_database_manager.cc
index 4f8a4564446d857b9a2ec2277cde39238fbe7c63..376d26edac729bd59e0727bb0a9588be447cd9e2 100644
--- a/components/safe_browsing_db/v4_local_database_manager.cc
+++ b/components/safe_browsing_db/v4_local_database_manager.cc
@@ -6,7 +6,6 @@
#include <vector>
-#include "base/callback.h"
#include "components/safe_browsing_db/safebrowsing.pb.h"
#include "content/public/browser/browser_thread.h"
@@ -14,12 +13,7 @@
namespace safe_browsing {
-V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path)
- : base_path_(base_path), enabled_(false) {
- DCHECK(!base_path_.empty());
- DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: "
- << "base_path_: " << base_path_.AsUTF8Unsafe();
-}
+V4LocalDatabaseManager::V4LocalDatabaseManager() : enabled_(false) {}
V4LocalDatabaseManager::~V4LocalDatabaseManager() {
DCHECK(!enabled_);
@@ -129,9 +123,8 @@
bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) {
// TODO(vakh): Implement this skeleton.
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (!enabled_) {
+ if (!enabled_)
return true;
- }
// Don't defer the resource load.
return true;
@@ -148,23 +141,13 @@
const V4ProtocolConfig& config) {
SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config);
- SetupUpdateProtocolManager(request_context_getter, config);
-
- SetupDatabase();
-
- enabled_ = true;
-}
-
-void V4LocalDatabaseManager::SetupUpdateProtocolManager(
- net::URLRequestContextGetter* request_context_getter,
- const V4ProtocolConfig& config) {
-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX)
+#if defined(OS_WIN) || defined (OS_LINUX) || defined (OS_MACOSX)
// TODO(vakh): Remove this if/endif block when the V4Database is implemented.
// Filed as http://crbug.com/608075
UpdateListIdentifier update_list_identifier;
#if defined(OS_WIN)
update_list_identifier.platform_type = WINDOWS_PLATFORM;
-#elif defined(OS_LINUX)
+#elif defined (OS_LINUX)
update_list_identifier.platform_type = LINUX_PLATFORM;
#else
update_list_identifier.platform_type = OSX_PLATFORM;
@@ -176,67 +159,28 @@
V4UpdateCallback callback = base::Bind(
&V4LocalDatabaseManager::UpdateRequestCompleted, base::Unretained(this));
-
v4_update_protocol_manager_ = V4UpdateProtocolManager::Create(
request_context_getter, config, current_list_states_, callback);
-}
-void V4LocalDatabaseManager::SetupDatabase() {
- DCHECK(!base_path_.empty());
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- // Only get a new task runner if there isn't one already. If the service has
- // previously been started and stopped, a task runner could already exist.
- if (!task_runner_) {
- base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
- task_runner_ = pool->GetSequencedTaskRunnerWithShutdownBehavior(
- pool->GetSequenceToken(), base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
- }
-
- // TODO(vakh): list_info_map should probably be a hard-coded map.
- ListInfoMap list_info_map;
-
- // Do not create the database on the IO thread since this may be an expensive
- // operation. Instead, do that on the task_runner and when the new database
- // has been created, swap it out on the IO thread.
- NewDatabaseReadyCallback db_ready_callback = base::Bind(
- &V4LocalDatabaseManager::DatabaseReady, base::Unretained(this));
- V4Database::Create(task_runner_, base_path_, list_info_map,
- db_ready_callback);
-}
-
-void V4LocalDatabaseManager::DatabaseReady(
- std::unique_ptr<V4Database> v4_database) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- v4_database_ = std::move(v4_database);
-
- // The database is in place. Start fetching updates now.
- v4_update_protocol_manager_->ScheduleNextUpdate();
+ enabled_ = true;
}
void V4LocalDatabaseManager::StopOnIOThread(bool shutdown) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- enabled_ = false;
-
- // Delete the V4Database.
- // Any pending writes to disk are completed.
- v4_database_.reset();
-
// Delete the V4UpdateProtocolManager.
// This cancels any in-flight update request.
- v4_update_protocol_manager_.reset();
+ if (v4_update_protocol_manager_.get()) {
+ v4_update_protocol_manager_.reset();
+ }
+ enabled_ = false;
SafeBrowsingDatabaseManager::StopOnIOThread(shutdown);
}
void V4LocalDatabaseManager::UpdateRequestCompleted(
const std::vector<ListUpdateResponse>& responses) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
// TODO(vakh): Updates downloaded. Store them on disk and record new state.
- v4_update_protocol_manager_->ScheduleNextUpdate();
}
} // namespace safe_browsing
« no previous file with comments | « components/safe_browsing_db/v4_local_database_manager.h ('k') | components/safe_browsing_db/v4_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698