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

Side by Side Diff: components/safe_browsing_db/v4_local_database_manager.cc

Issue 2648193002: SafeBrowsing: Move enabled_ to base class DB Manager (Closed)
Patch Set: Fix compile error Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file should not be build on Android but is currently getting built. 5 // This file should not be build on Android but is currently getting built.
6 // TODO(vakh): Fix that: http://crbug.com/621647 6 // TODO(vakh): Fix that: http://crbug.com/621647
7 7
8 #include "components/safe_browsing_db/v4_local_database_manager.h" 8 #include "components/safe_browsing_db/v4_local_database_manager.h"
9 9
10 #include <vector> 10 #include <vector>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const base::FilePath& base_path) { 131 const base::FilePath& base_path) {
132 if (!V4FeatureList::IsLocalDatabaseManagerEnabled()) { 132 if (!V4FeatureList::IsLocalDatabaseManagerEnabled()) {
133 return nullptr; 133 return nullptr;
134 } 134 }
135 135
136 return make_scoped_refptr(new V4LocalDatabaseManager(base_path)); 136 return make_scoped_refptr(new V4LocalDatabaseManager(base_path));
137 } 137 }
138 138
139 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) 139 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path)
140 : base_path_(base_path), 140 : base_path_(base_path),
141 enabled_(false),
142 list_infos_(GetListInfos()), 141 list_infos_(GetListInfos()),
143 weak_factory_(this) { 142 weak_factory_(this) {
144 DCHECK(!base_path_.empty()); 143 DCHECK(!base_path_.empty());
145 DCHECK(!list_infos_.empty()); 144 DCHECK(!list_infos_.empty());
146 145
147 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " 146 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: "
148 << "base_path_: " << base_path_.AsUTF8Unsafe(); 147 << "base_path_: " << base_path_.AsUTF8Unsafe();
149 } 148 }
150 149
151 V4LocalDatabaseManager::~V4LocalDatabaseManager() { 150 V4LocalDatabaseManager::~V4LocalDatabaseManager() {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 void V4LocalDatabaseManager::StartOnIOThread( 360 void V4LocalDatabaseManager::StartOnIOThread(
362 net::URLRequestContextGetter* request_context_getter, 361 net::URLRequestContextGetter* request_context_getter,
363 const V4ProtocolConfig& config) { 362 const V4ProtocolConfig& config) {
364 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config); 363 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config);
365 364
366 db_updated_callback_ = base::Bind(&V4LocalDatabaseManager::DatabaseUpdated, 365 db_updated_callback_ = base::Bind(&V4LocalDatabaseManager::DatabaseUpdated,
367 weak_factory_.GetWeakPtr()); 366 weak_factory_.GetWeakPtr());
368 367
369 SetupUpdateProtocolManager(request_context_getter, config); 368 SetupUpdateProtocolManager(request_context_getter, config);
370 SetupDatabase(); 369 SetupDatabase();
371
372 enabled_ = true;
373 } 370 }
374 371
375 void V4LocalDatabaseManager::StopOnIOThread(bool shutdown) { 372 void V4LocalDatabaseManager::StopOnIOThread(bool shutdown) {
376 DCHECK_CURRENTLY_ON(BrowserThread::IO); 373 DCHECK_CURRENTLY_ON(BrowserThread::IO);
377 374
378 enabled_ = false;
379
380 pending_checks_.clear(); 375 pending_checks_.clear();
381 376
382 RespondSafeToQueuedChecks(); 377 RespondSafeToQueuedChecks();
383 378
384 // Delete the V4Database. Any pending writes to disk are completed. 379 // Delete the V4Database. Any pending writes to disk are completed.
385 // This operation happens on the task_runner on which v4_database_ operates 380 // This operation happens on the task_runner on which v4_database_ operates
386 // and doesn't block the IO thread. 381 // and doesn't block the IO thread.
387 V4Database::Destroy(std::move(v4_database_)); 382 V4Database::Destroy(std::move(v4_database_));
388 383
389 // Delete the V4UpdateProtocolManager. 384 // Delete the V4UpdateProtocolManager.
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 db_updated_callback_); 718 db_updated_callback_);
724 } 719 }
725 720
726 bool V4LocalDatabaseManager::AreStoresAvailableNow( 721 bool V4LocalDatabaseManager::AreStoresAvailableNow(
727 const StoresToCheck& stores_to_check) const { 722 const StoresToCheck& stores_to_check) const {
728 return enabled_ && v4_database_ && 723 return enabled_ && v4_database_ &&
729 v4_database_->AreStoresAvailable(stores_to_check); 724 v4_database_->AreStoresAvailable(stores_to_check);
730 } 725 }
731 726
732 } // namespace safe_browsing 727 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698