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

Retire ScopedObserver in /components/omnibox.

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

Bug: 1145565
Change-Id: Id17e64fb0132a99c583e2670c5cd84fb2f34bc8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533154
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826764}
parent f23104a7
...@@ -31,11 +31,10 @@ bool FaviconCache::Request::operator<(const Request& rhs) const { ...@@ -31,11 +31,10 @@ bool FaviconCache::Request::operator<(const Request& rhs) const {
FaviconCache::FaviconCache(favicon::FaviconService* favicon_service, FaviconCache::FaviconCache(favicon::FaviconService* favicon_service,
history::HistoryService* history_service) history::HistoryService* history_service)
: favicon_service_(favicon_service), : favicon_service_(favicon_service),
history_observer_(this),
mru_cache_(GetFaviconCacheSize()), mru_cache_(GetFaviconCacheSize()),
responses_without_favicons_(GetFaviconCacheSize()) { responses_without_favicons_(GetFaviconCacheSize()) {
if (history_service) { if (history_service) {
history_observer_.Add(history_service); history_observation_.Observe(history_service);
favicons_changed_subscription_ = favicons_changed_subscription_ =
history_service->AddFaviconsChangedCallback(base::BindRepeating( history_service->AddFaviconsChangedCallback(base::BindRepeating(
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "base/containers/mru_cache.h" #include "base/containers/mru_cache.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.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 "components/favicon_base/favicon_types.h" #include "components/favicon_base/favicon_types.h"
#include "components/history/core/browser/history_service.h" #include "components/history/core/browser/history_service.h"
...@@ -132,8 +132,9 @@ class FaviconCache : public history::HistoryServiceObserver { ...@@ -132,8 +132,9 @@ class FaviconCache : public history::HistoryServiceObserver {
// Non-owning pointer to a KeyedService. // Non-owning pointer to a KeyedService.
favicon::FaviconService* favicon_service_; favicon::FaviconService* favicon_service_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver> base::ScopedObservation<history::HistoryService,
history_observer_{this}; history::HistoryServiceObserver>
history_observation_{this};
base::CancelableTaskTracker task_tracker_; base::CancelableTaskTracker task_tracker_;
std::map<Request, std::list<FaviconFetchedCallback>> pending_requests_; std::map<Request, std::list<FaviconFetchedCallback>> pending_requests_;
......
...@@ -76,9 +76,10 @@ void WaitForURLsDeletedObserver::OnURLsDeleted( ...@@ -76,9 +76,10 @@ void WaitForURLsDeletedObserver::OnURLsDeleted(
void WaitForURLsDeletedNotification(history::HistoryService* history_service) { void WaitForURLsDeletedNotification(history::HistoryService* history_service) {
base::RunLoop runner; base::RunLoop runner;
WaitForURLsDeletedObserver observer(&runner); WaitForURLsDeletedObserver observer(&runner);
ScopedObserver<history::HistoryService, history::HistoryServiceObserver> base::ScopedObservation<history::HistoryService,
scoped_observer(&observer); history::HistoryServiceObserver>
scoped_observer.Add(history_service); scoped_observation(&observer);
scoped_observation.Observe(history_service);
runner.Run(); runner.Run();
} }
......
...@@ -148,7 +148,7 @@ SearchProvider::SearchProvider(AutocompleteProviderClient* client, ...@@ -148,7 +148,7 @@ SearchProvider::SearchProvider(AutocompleteProviderClient* client,
// |template_url_service| can be null in tests. // |template_url_service| can be null in tests.
if (template_url_service) if (template_url_service)
observer_.Add(template_url_service); observation_.Observe(template_url_service);
} }
// static // static
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "components/omnibox/browser/answers_cache.h" #include "components/omnibox/browser/answers_cache.h"
...@@ -428,8 +428,8 @@ class SearchProvider : public BaseSearchProvider, ...@@ -428,8 +428,8 @@ class SearchProvider : public BaseSearchProvider,
AnswersCache answers_cache_; // Cache for last answers seen. AnswersCache answers_cache_; // Cache for last answers seen.
AnswersQueryData prefetch_data_; // Data to use for query prefetching. AnswersQueryData prefetch_data_; // Data to use for query prefetching.
ScopedObserver<TemplateURLService, TemplateURLServiceObserver> observer_{ base::ScopedObservation<TemplateURLService, TemplateURLServiceObserver>
this}; observation_{this};
}; };
#endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_PROVIDER_H_ #endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_PROVIDER_H_
...@@ -83,7 +83,7 @@ ShortcutsBackend::ShortcutsBackend( ...@@ -83,7 +83,7 @@ ShortcutsBackend::ShortcutsBackend(
if (!suppress_db) if (!suppress_db)
db_ = new ShortcutsDatabase(database_path); db_ = new ShortcutsDatabase(database_path);
if (history_service) if (history_service)
history_service_observer_.Add(history_service); history_service_observation_.Observe(history_service);
} }
bool ShortcutsBackend::Init() { bool ShortcutsBackend::Init() {
...@@ -190,7 +190,8 @@ ShortcutsDatabase::Shortcut::MatchCore ShortcutsBackend::MatchToMatchCore( ...@@ -190,7 +190,8 @@ ShortcutsDatabase::Shortcut::MatchCore ShortcutsBackend::MatchToMatchCore(
} }
void ShortcutsBackend::ShutdownOnUIThread() { void ShortcutsBackend::ShutdownOnUIThread() {
history_service_observer_.RemoveAll(); if (history_service_observation_.IsObserving())
history_service_observation_.RemoveObservation();
} }
void ShortcutsBackend::OnURLsDeleted( void ShortcutsBackend::OnURLsDeleted(
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
...@@ -170,8 +170,9 @@ class ShortcutsBackend : public RefcountedKeyedService, ...@@ -170,8 +170,9 @@ class ShortcutsBackend : public RefcountedKeyedService,
// This is a helper map for quick access to a shortcut by guid. // This is a helper map for quick access to a shortcut by guid.
GuidMap guid_map_; GuidMap guid_map_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver> base::ScopedObservation<history::HistoryService,
history_service_observer_{this}; history::HistoryServiceObserver>
history_service_observation_{this};
scoped_refptr<base::SequencedTaskRunner> main_runner_; scoped_refptr<base::SequencedTaskRunner> main_runner_;
scoped_refptr<base::SequencedTaskRunner> db_runner_; scoped_refptr<base::SequencedTaskRunner> db_runner_;
......
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