Commit 6d5e123d authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /components/safe_browsing.

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=drubery@chromium.org

Bug: 1145565
Change-Id: Id8d8c10f96b678c33a07d9526a3dc495db69f356
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532721
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826566}
parent 70c63541
......@@ -24,7 +24,7 @@ ThreatDetailsRedirectsCollector::ThreatDetailsRedirectsCollector(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (history_service) {
history_service_observer_.Add(history_service.get());
history_service_observation_.Observe(history_service.get());
}
}
......@@ -111,7 +111,8 @@ void ThreatDetailsRedirectsCollector::AllDone() {
void ThreatDetailsRedirectsCollector::HistoryServiceBeingDeleted(
history::HistoryService* history_service) {
history_service_observer_.Remove(history_service);
DCHECK(history_service_observation_.IsObservingSource(history_service));
history_service_observation_.RemoveObservation();
history_service_.reset();
}
......
......@@ -13,7 +13,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/history/core/browser/history_service.h"
......@@ -76,8 +76,9 @@ class ThreatDetailsRedirectsCollector
std::vector<RedirectChain> redirects_urls_;
base::WeakPtr<history::HistoryService> history_service_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
history_service_observer_{this};
base::ScopedObservation<history::HistoryService,
history::HistoryServiceObserver>
history_service_observation_{this};
DISALLOW_COPY_AND_ASSIGN(ThreatDetailsRedirectsCollector);
};
......
......@@ -372,7 +372,7 @@ VerdictCacheManager::VerdictCacheManager(
stored_verdict_count_real_time_url_check_(base::nullopt),
content_settings_(content_settings) {
if (history_service)
history_service_observer_.Add(history_service);
history_service_observation_.Observe(history_service);
if (!content_settings->IsOffTheRecord()) {
ScheduleNextCleanUpAfterInterval(
base::TimeDelta::FromSeconds(kCleanUpIntervalInitSecond));
......@@ -382,7 +382,8 @@ VerdictCacheManager::VerdictCacheManager(
void VerdictCacheManager::Shutdown() {
CleanUpExpiredVerdicts();
history_service_observer_.RemoveAll();
if (history_service_observation_.IsObserving())
history_service_observation_.RemoveObservation();
weak_factory_.InvalidateWeakPtrs();
}
......@@ -688,7 +689,8 @@ void VerdictCacheManager::OnURLsDeleted(
// Overridden from history::HistoryServiceObserver.
void VerdictCacheManager::HistoryServiceBeingDeleted(
history::HistoryService* history_service) {
history_service_observer_.Remove(history_service);
DCHECK(history_service_observation_.IsObservingSource(history_service));
history_service_observation_.RemoveObservation();
}
bool VerdictCacheManager::RemoveExpiredPhishGuardVerdicts(
......
......@@ -8,7 +8,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/values.h"
......@@ -156,8 +156,9 @@ class VerdictCacheManager : public history::HistoryServiceObserver,
// Number of verdict stored for this profile for real time url check pings.
base::Optional<size_t> stored_verdict_count_real_time_url_check_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
history_service_observer_{this};
base::ScopedObservation<history::HistoryService,
history::HistoryServiceObserver>
history_service_observation_{this};
// Content settings maps associated with this instance.
scoped_refptr<HostContentSettingsMap> content_settings_;
......
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