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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 2821193005: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/safe_browsing (Closed)
Patch Set: Created 3 years, 8 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/safe_browsing_service.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 Stop(true); 359 Stop(true);
360 360
361 services_delegate_->ShutdownServices(); 361 services_delegate_->ShutdownServices();
362 362
363 // Since URLRequestContextGetters are refcounted, can't count on clearing 363 // Since URLRequestContextGetters are refcounted, can't count on clearing
364 // |url_request_context_getter_| to delete it, so need to shut it down first, 364 // |url_request_context_getter_| to delete it, so need to shut it down first,
365 // which will cancel any requests that are currently using it, and prevent 365 // which will cancel any requests that are currently using it, and prevent
366 // new requests from using it as well. 366 // new requests from using it as well.
367 BrowserThread::PostNonNestableTask( 367 BrowserThread::PostNonNestableTask(
368 BrowserThread::IO, FROM_HERE, 368 BrowserThread::IO, FROM_HERE,
369 base::Bind(&SafeBrowsingURLRequestContextGetter::ServiceShuttingDown, 369 base::BindOnce(&SafeBrowsingURLRequestContextGetter::ServiceShuttingDown,
370 url_request_context_getter_)); 370 url_request_context_getter_));
371 371
372 // Release the URLRequestContextGetter after passing it to the IOThread. It 372 // Release the URLRequestContextGetter after passing it to the IOThread. It
373 // has to be released now rather than in the destructor because it can only 373 // has to be released now rather than in the destructor because it can only
374 // be deleted on the IOThread, and the SafeBrowsingService outlives the IO 374 // be deleted on the IOThread, and the SafeBrowsingService outlives the IO
375 // thread. 375 // thread.
376 url_request_context_getter_ = nullptr; 376 url_request_context_getter_ = nullptr;
377 } 377 }
378 378
379 bool SafeBrowsingService::DownloadBinHashNeeded() const { 379 bool SafeBrowsingService::DownloadBinHashNeeded() const {
380 DCHECK_CURRENTLY_ON(BrowserThread::UI); 380 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 461
462 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) { 462 void SafeBrowsingService::OnResourceRequest(const net::URLRequest* request) {
463 #if defined(FULL_SAFE_BROWSING) 463 #if defined(FULL_SAFE_BROWSING)
464 DCHECK_CURRENTLY_ON(BrowserThread::IO); 464 DCHECK_CURRENTLY_ON(BrowserThread::IO);
465 TRACE_EVENT1("loader", "SafeBrowsingService::OnResourceRequest", "url", 465 TRACE_EVENT1("loader", "SafeBrowsingService::OnResourceRequest", "url",
466 request->url().spec()); 466 request->url().spec());
467 467
468 ResourceRequestInfo info = ResourceRequestDetector::GetRequestInfo(request); 468 ResourceRequestInfo info = ResourceRequestDetector::GetRequestInfo(request);
469 BrowserThread::PostTask( 469 BrowserThread::PostTask(
470 BrowserThread::UI, FROM_HERE, 470 BrowserThread::UI, FROM_HERE,
471 base::Bind(&SafeBrowsingService::ProcessResourceRequest, this, info)); 471 base::BindOnce(&SafeBrowsingService::ProcessResourceRequest, this, info));
472 #endif 472 #endif
473 } 473 }
474 474
475 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() { 475 SafeBrowsingUIManager* SafeBrowsingService::CreateUIManager() {
476 return new SafeBrowsingUIManager(this); 476 return new SafeBrowsingUIManager(this);
477 } 477 }
478 478
479 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() { 479 SafeBrowsingDatabaseManager* SafeBrowsingService::CreateDatabaseManager() {
480 #if defined(SAFE_BROWSING_DB_LOCAL) 480 #if defined(SAFE_BROWSING_DB_LOCAL)
481 return new LocalSafeBrowsingDatabaseManager(this); 481 return new LocalSafeBrowsingDatabaseManager(this);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 #endif 618 #endif
619 ping_manager_.reset(); 619 ping_manager_.reset();
620 } 620 }
621 } 621 }
622 622
623 void SafeBrowsingService::Start() { 623 void SafeBrowsingService::Start() {
624 DCHECK_CURRENTLY_ON(BrowserThread::UI); 624 DCHECK_CURRENTLY_ON(BrowserThread::UI);
625 625
626 BrowserThread::PostTask( 626 BrowserThread::PostTask(
627 BrowserThread::IO, FROM_HERE, 627 BrowserThread::IO, FROM_HERE,
628 base::Bind(&SafeBrowsingService::StartOnIOThread, this, 628 base::BindOnce(&SafeBrowsingService::StartOnIOThread, this,
629 base::RetainedRef(url_request_context_getter_))); 629 base::RetainedRef(url_request_context_getter_)));
630 } 630 }
631 631
632 void SafeBrowsingService::Stop(bool shutdown) { 632 void SafeBrowsingService::Stop(bool shutdown) {
633 BrowserThread::PostTask( 633 BrowserThread::PostTask(
634 BrowserThread::IO, FROM_HERE, 634 BrowserThread::IO, FROM_HERE,
635 base::Bind(&SafeBrowsingService::StopOnIOThread, this, shutdown)); 635 base::BindOnce(&SafeBrowsingService::StopOnIOThread, this, shutdown));
636 } 636 }
637 637
638 void SafeBrowsingService::Observe(int type, 638 void SafeBrowsingService::Observe(int type,
639 const content::NotificationSource& source, 639 const content::NotificationSource& source,
640 const content::NotificationDetails& details) { 640 const content::NotificationDetails& details) {
641 switch (type) { 641 switch (type) {
642 case chrome::NOTIFICATION_PROFILE_CREATED: { 642 case chrome::NOTIFICATION_PROFILE_CREATED: {
643 DCHECK_CURRENTLY_ON(BrowserThread::UI); 643 DCHECK_CURRENTLY_ON(BrowserThread::UI);
644 Profile* profile = content::Source<Profile>(source).ptr(); 644 Profile* profile = content::Source<Profile>(source).ptr();
645 CreatePasswordProtectionService(profile); 645 CreatePasswordProtectionService(profile);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 state_callback_list_.Notify(); 737 state_callback_list_.Notify();
738 738
739 services_delegate_->RefreshState(enabled_by_prefs_); 739 services_delegate_->RefreshState(enabled_by_prefs_);
740 } 740 }
741 741
742 void SafeBrowsingService::SendSerializedDownloadReport( 742 void SafeBrowsingService::SendSerializedDownloadReport(
743 const std::string& report) { 743 const std::string& report) {
744 DCHECK_CURRENTLY_ON(BrowserThread::UI); 744 DCHECK_CURRENTLY_ON(BrowserThread::UI);
745 BrowserThread::PostTask( 745 BrowserThread::PostTask(
746 BrowserThread::IO, FROM_HERE, 746 BrowserThread::IO, FROM_HERE,
747 base::Bind(&SafeBrowsingService::OnSendSerializedDownloadReport, this, 747 base::BindOnce(&SafeBrowsingService::OnSendSerializedDownloadReport, this,
748 report)); 748 report));
749 } 749 }
750 750
751 void SafeBrowsingService::OnSendSerializedDownloadReport( 751 void SafeBrowsingService::OnSendSerializedDownloadReport(
752 const std::string& report) { 752 const std::string& report) {
753 DCHECK_CURRENTLY_ON(BrowserThread::IO); 753 DCHECK_CURRENTLY_ON(BrowserThread::IO);
754 if (ping_manager()) 754 if (ping_manager())
755 ping_manager()->ReportThreatDetails(report); 755 ping_manager()->ReportThreatDetails(report);
756 } 756 }
757 757
758 void SafeBrowsingService::ProcessResourceRequest( 758 void SafeBrowsingService::ProcessResourceRequest(
(...skipping 14 matching lines...) Expand all
773 773
774 void SafeBrowsingService::RemovePasswordProtectionService(Profile* profile) { 774 void SafeBrowsingService::RemovePasswordProtectionService(Profile* profile) {
775 DCHECK_CURRENTLY_ON(BrowserThread::UI); 775 DCHECK_CURRENTLY_ON(BrowserThread::UI);
776 DCHECK(profile); 776 DCHECK(profile);
777 auto it = password_protection_service_map_.find(profile); 777 auto it = password_protection_service_map_.find(profile);
778 if (it != password_protection_service_map_.end()) 778 if (it != password_protection_service_map_.end())
779 password_protection_service_map_.erase(it); 779 password_protection_service_map_.erase(it);
780 } 780 }
781 781
782 } // namespace safe_browsing 782 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698