Commit 74d6858f authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /components/safe_browsing/content/password_protection.

ScopedObserver is being deprecated in favor of two new classes:
- base::ScopedObservation for observers that only ever observe
  a single source.
- base::ScopedMultiSourceObservation for observers that do or may
  observe more than a single source.

This CL was uploaded by git cl split.

R=bdea@chromium.org

Bug: 1145565
Change-Id: I852404bcc8df54aaa7273fd69ec47b80b0b44235
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533155
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarBettina Dea <bdea@chromium.org>
Commit-Queue: Bettina Dea <bdea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826570}
parent 7b6fd275
...@@ -61,7 +61,7 @@ PasswordProtectionService::PasswordProtectionService( ...@@ -61,7 +61,7 @@ PasswordProtectionService::PasswordProtectionService(
url_loader_factory_(url_loader_factory) { url_loader_factory_(url_loader_factory) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (history_service) if (history_service)
history_service_observer_.Add(history_service); history_service_observation_.Observe(history_service);
common_spoofed_domains_ = {"login.live.com", "facebook.com", "box.com", common_spoofed_domains_ = {"login.live.com", "facebook.com", "box.com",
"google.com", "paypal.com", "apple.com", "google.com", "paypal.com", "apple.com",
...@@ -72,7 +72,8 @@ PasswordProtectionService::PasswordProtectionService( ...@@ -72,7 +72,8 @@ PasswordProtectionService::PasswordProtectionService(
PasswordProtectionService::~PasswordProtectionService() { PasswordProtectionService::~PasswordProtectionService() {
tracker_.TryCancelAll(); tracker_.TryCancelAll();
CancelPendingRequests(); CancelPendingRequests();
history_service_observer_.RemoveAll(); if (history_service_observation_.IsObserving())
history_service_observation_.RemoveObservation();
weak_factory_.InvalidateWeakPtrs(); weak_factory_.InvalidateWeakPtrs();
} }
...@@ -403,7 +404,8 @@ void PasswordProtectionService::OnURLsDeleted( ...@@ -403,7 +404,8 @@ void PasswordProtectionService::OnURLsDeleted(
void PasswordProtectionService::HistoryServiceBeingDeleted( void PasswordProtectionService::HistoryServiceBeingDeleted(
history::HistoryService* history_service) { history::HistoryService* history_service) {
history_service_observer_.RemoveAll(); DCHECK(history_service_observation_.IsObservingSource(history_service));
history_service_observation_.RemoveObservation();
} }
std::unique_ptr<PasswordProtectionNavigationThrottle> std::unique_ptr<PasswordProtectionNavigationThrottle>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/task/cancelable_task_tracker.h" #include "base/task/cancelable_task_tracker.h"
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -522,8 +522,9 @@ class PasswordProtectionService : public history::HistoryServiceObserver { ...@@ -522,8 +522,9 @@ class PasswordProtectionService : public history::HistoryServiceObserver {
// dialog. // dialog.
std::list<std::string> common_spoofed_domains_; std::list<std::string> common_spoofed_domains_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver> base::ScopedObservation<history::HistoryService,
history_service_observer_{this}; history::HistoryServiceObserver>
history_service_observation_{this};
// Weakptr can only cancel task if it is posted to the same thread. Therefore, // Weakptr can only cancel task if it is posted to the same thread. Therefore,
// we need CancelableTaskTracker to cancel tasks posted to IO thread. // we need CancelableTaskTracker to cancel tasks posted to IO thread.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment