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

Side by Side Diff: chrome/browser/safe_browsing/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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/safe_browsing/local_database_manager.h" 5 #include "chrome/browser/safe_browsing/local_database_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 264 }
265 } else { 265 } else {
266 NOTREACHED(); 266 NOTREACHED();
267 } 267 }
268 } 268 }
269 269
270 LocalSafeBrowsingDatabaseManager::LocalSafeBrowsingDatabaseManager( 270 LocalSafeBrowsingDatabaseManager::LocalSafeBrowsingDatabaseManager(
271 const scoped_refptr<SafeBrowsingService>& service) 271 const scoped_refptr<SafeBrowsingService>& service)
272 : sb_service_(service), 272 : sb_service_(service),
273 database_(NULL), 273 database_(NULL),
274 enabled_(false),
275 enable_download_protection_(false), 274 enable_download_protection_(false),
276 enable_csd_whitelist_(false), 275 enable_csd_whitelist_(false),
277 enable_download_whitelist_(false), 276 enable_download_whitelist_(false),
278 enable_extension_blacklist_(false), 277 enable_extension_blacklist_(false),
279 enable_ip_blacklist_(false), 278 enable_ip_blacklist_(false),
280 enable_unwanted_software_blacklist_(true), 279 enable_unwanted_software_blacklist_(true),
281 enable_module_whitelist_(true), 280 enable_module_whitelist_(true),
282 update_in_progress_(false), 281 update_in_progress_(false),
283 database_update_in_progress_(false), 282 database_update_in_progress_(false),
284 closing_database_(false), 283 closing_database_(false),
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 DCHECK(enabled_); 662 DCHECK(enabled_);
664 safe_browsing_task_runner_->PostTask( 663 safe_browsing_task_runner_->PostTask(
665 FROM_HERE, 664 FROM_HERE,
666 base::Bind(&LocalSafeBrowsingDatabaseManager::OnResetDatabase, this)); 665 base::Bind(&LocalSafeBrowsingDatabaseManager::OnResetDatabase, this));
667 } 666 }
668 667
669 void LocalSafeBrowsingDatabaseManager::StartOnIOThread( 668 void LocalSafeBrowsingDatabaseManager::StartOnIOThread(
670 net::URLRequestContextGetter* request_context_getter, 669 net::URLRequestContextGetter* request_context_getter,
671 const V4ProtocolConfig& config) { 670 const V4ProtocolConfig& config) {
672 DCHECK_CURRENTLY_ON(BrowserThread::IO); 671 DCHECK_CURRENTLY_ON(BrowserThread::IO);
673 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config);
674 672
675 if (enabled_) 673 if (enabled_)
676 return; 674 return;
677 675
678 // Only get a new task runner if there isn't one already. If the service has 676 // Only get a new task runner if there isn't one already. If the service has
679 // previously been started and stopped, a task runner could already exist. 677 // previously been started and stopped, a task runner could already exist.
680 if (!safe_browsing_task_runner_) { 678 if (!safe_browsing_task_runner_) {
681 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 679 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
682 safe_browsing_task_runner_ = 680 safe_browsing_task_runner_ =
683 pool->GetSequencedTaskRunnerWithShutdownBehavior( 681 pool->GetSequencedTaskRunnerWithShutdownBehavior(
684 pool->GetSequenceToken(), 682 pool->GetSequenceToken(),
685 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 683 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
686 } 684 }
687 685
688 enabled_ = true; 686 // Call this after the enabled_ check. It will set enabled_ to true.
687 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config);
689 688
690 MakeDatabaseAvailable(); 689 MakeDatabaseAvailable();
691 } 690 }
692 691
693 void LocalSafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { 692 void LocalSafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) {
694 DCHECK_CURRENTLY_ON(BrowserThread::IO); 693 DCHECK_CURRENTLY_ON(BrowserThread::IO);
695 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown);
696 694
697 DoStopOnIOThread(); 695 DoStopOnIOThread();
698 if (shutdown) { 696 if (shutdown) {
699 sb_service_ = NULL; 697 sb_service_ = NULL;
700 } 698 }
699
700 // Call this last. It will set enabled_ to false.
701 SafeBrowsingDatabaseManager::StopOnIOThread(shutdown);
Nathan Parker 2017/01/23 23:32:34 I think we should set enabled_=false at the top of
kcarattini 2017/01/24 03:21:23 Done (I think). Now only the subclasses set enable
701 } 702 }
702 703
703 void LocalSafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( 704 void LocalSafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished(
704 bool update_succeeded) { 705 bool update_succeeded) {
705 DCHECK_CURRENTLY_ON(BrowserThread::UI); 706 DCHECK_CURRENTLY_ON(BrowserThread::UI);
706 content::NotificationService::current()->Notify( 707 content::NotificationService::current()->Notify(
707 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 708 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
708 content::Source<SafeBrowsingDatabaseManager>(this), 709 content::Source<SafeBrowsingDatabaseManager>(this),
709 content::Details<bool>(&update_succeeded)); 710 content::Details<bool>(&update_succeeded));
710 } 711 }
(...skipping 14 matching lines...) Expand all
725 const QueuedCheck& other) = default; 726 const QueuedCheck& other) = default;
726 727
727 LocalSafeBrowsingDatabaseManager::QueuedCheck::~QueuedCheck() {} 728 LocalSafeBrowsingDatabaseManager::QueuedCheck::~QueuedCheck() {}
728 729
729 void LocalSafeBrowsingDatabaseManager::DoStopOnIOThread() { 730 void LocalSafeBrowsingDatabaseManager::DoStopOnIOThread() {
730 DCHECK_CURRENTLY_ON(BrowserThread::IO); 731 DCHECK_CURRENTLY_ON(BrowserThread::IO);
731 732
732 if (!enabled_) 733 if (!enabled_)
733 return; 734 return;
734 735
735 enabled_ = false;
736
737 // Delete queued checks, calling back any clients with 'SB_THREAT_TYPE_SAFE'. 736 // Delete queued checks, calling back any clients with 'SB_THREAT_TYPE_SAFE'.
738 while (!queued_checks_.empty()) { 737 while (!queued_checks_.empty()) {
739 QueuedCheck queued = queued_checks_.front(); 738 QueuedCheck queued = queued_checks_.front();
740 if (queued.client) { 739 if (queued.client) {
741 SafeBrowsingCheck sb_check(std::vector<GURL>(1, queued.url), 740 SafeBrowsingCheck sb_check(std::vector<GURL>(1, queued.url),
742 std::vector<SBFullHash>(), queued.client, 741 std::vector<SBFullHash>(), queued.client,
743 queued.check_type, queued.expected_threats); 742 queued.check_type, queued.expected_threats);
744 sb_check.OnSafeBrowsingResult(); 743 sb_check.OnSafeBrowsingResult();
745 } 744 }
746 queued_checks_.pop_front(); 745 queued_checks_.pop_front();
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, 1241 base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback,
1243 check_ptr->weak_ptr_factory_->GetWeakPtr(), check_ptr), 1242 check_ptr->weak_ptr_factory_->GetWeakPtr(), check_ptr),
1244 check_timeout_); 1243 check_timeout_);
1245 } 1244 }
1246 1245
1247 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const { 1246 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const {
1248 return enable_download_protection_; 1247 return enable_download_protection_;
1249 } 1248 }
1250 1249
1251 } // namespace safe_browsing 1250 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.h ('k') | components/safe_browsing_db/database_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698