Commit f23104a7 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /components/search.

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

Bug: 1145565
Change-Id: Ib3a00c095ae3210e9ca78c073685b48863388d03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532659
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826763}
parent 1281d4c0
......@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram_functions.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/stl_util.h"
#include "base/values.h"
#include "components/history/core/browser/history_service.h"
......@@ -84,7 +84,7 @@ class RepeatableQueriesService::SigninObserver
base::RepeatingClosure callback)
: identity_manager_(identity_manager), callback_(std::move(callback)) {
if (identity_manager_) {
identity_manager_observer_.Add(identity_manager_);
identity_manager_observation_.Observe(identity_manager_);
}
}
~SigninObserver() override = default;
......@@ -103,8 +103,9 @@ class RepeatableQueriesService::SigninObserver
callback_.Run();
}
ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
identity_manager_observer_{this};
base::ScopedObservation<signin::IdentityManager,
signin::IdentityManager::Observer>
identity_manager_observation_{this};
// May be nullptr in tests.
signin::IdentityManager* const identity_manager_;
base::RepeatingClosure callback_;
......
......@@ -11,7 +11,7 @@ SearchProviderObserver::SearchProviderObserver(TemplateURLService* service,
is_google_(search::DefaultSearchProviderIsGoogle(service_)),
callback_(std::move(callback)) {
if (service_) {
service_observer_.Add(service_);
service_observation_.Observe(service_);
}
}
......@@ -29,6 +29,7 @@ void SearchProviderObserver::OnTemplateURLServiceChanged() {
void SearchProviderObserver::OnTemplateURLServiceShuttingDown() {
DCHECK(service_);
service_observer_.Remove(service_);
DCHECK(service_observation_.IsObservingSource(service_));
service_observation_.RemoveObservation();
service_ = nullptr;
}
......@@ -5,7 +5,7 @@
#ifndef COMPONENTS_SEARCH_SEARCH_PROVIDER_OBSERVER_H_
#define COMPONENTS_SEARCH_SEARCH_PROVIDER_OBSERVER_H_
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_observer.h"
......@@ -25,8 +25,8 @@ class SearchProviderObserver : public TemplateURLServiceObserver {
void OnTemplateURLServiceChanged() override;
void OnTemplateURLServiceShuttingDown() override;
ScopedObserver<TemplateURLService, TemplateURLServiceObserver>
service_observer_{this};
base::ScopedObservation<TemplateURLService, TemplateURLServiceObserver>
service_observation_{this};
// May be nullptr in tests.
TemplateURLService* service_;
bool is_google_;
......
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