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 {
FaviconCache::FaviconCache(favicon::FaviconService* favicon_service,
history::HistoryService* history_service)
: favicon_service_(favicon_service),
history_observer_(this),
mru_cache_(GetFaviconCacheSize()),
responses_without_favicons_(GetFaviconCacheSize()) {
if (history_service) {
history_observer_.Add(history_service);
history_observation_.Observe(history_service);
favicons_changed_subscription_ =
history_service->AddFaviconsChangedCallback(base::BindRepeating(
......
......@@ -13,7 +13,7 @@
#include "base/containers/mru_cache.h"
#include "base/gtest_prod_util.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 "components/favicon_base/favicon_types.h"
#include "components/history/core/browser/history_service.h"
......@@ -132,8 +132,9 @@ class FaviconCache : public history::HistoryServiceObserver {
// Non-owning pointer to a KeyedService.
favicon::FaviconService* favicon_service_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
history_observer_{this};
base::ScopedObservation<history::HistoryService,
history::HistoryServiceObserver>
history_observation_{this};
base::CancelableTaskTracker task_tracker_;
std::map<Request, std::list<FaviconFetchedCallback>> pending_requests_;
......
......@@ -76,9 +76,10 @@ void WaitForURLsDeletedObserver::OnURLsDeleted(
void WaitForURLsDeletedNotification(history::HistoryService* history_service) {
base::RunLoop runner;
WaitForURLsDeletedObserver observer(&runner);
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
scoped_observer(&observer);
scoped_observer.Add(history_service);
base::ScopedObservation<history::HistoryService,
history::HistoryServiceObserver>
scoped_observation(&observer);
scoped_observation.Observe(history_service);
runner.Run();
}
......
......@@ -148,7 +148,7 @@ SearchProvider::SearchProvider(AutocompleteProviderClient* client,
// |template_url_service| can be null in tests.
if (template_url_service)
observer_.Add(template_url_service);
observation_.Observe(template_url_service);
}
// static
......
......@@ -17,7 +17,7 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "components/omnibox/browser/answers_cache.h"
......@@ -428,8 +428,8 @@ class SearchProvider : public BaseSearchProvider,
AnswersCache answers_cache_; // Cache for last answers seen.
AnswersQueryData prefetch_data_; // Data to use for query prefetching.
ScopedObserver<TemplateURLService, TemplateURLServiceObserver> observer_{
this};
base::ScopedObservation<TemplateURLService, TemplateURLServiceObserver>
observation_{this};
};
#endif // COMPONENTS_OMNIBOX_BROWSER_SEARCH_PROVIDER_H_
......@@ -83,7 +83,7 @@ ShortcutsBackend::ShortcutsBackend(
if (!suppress_db)
db_ = new ShortcutsDatabase(database_path);
if (history_service)
history_service_observer_.Add(history_service);
history_service_observation_.Observe(history_service);
}
bool ShortcutsBackend::Init() {
......@@ -190,7 +190,8 @@ ShortcutsDatabase::Shortcut::MatchCore ShortcutsBackend::MatchToMatchCore(
}
void ShortcutsBackend::ShutdownOnUIThread() {
history_service_observer_.RemoveAll();
if (history_service_observation_.IsObserving())
history_service_observation_.RemoveObservation();
}
void ShortcutsBackend::OnURLsDeleted(
......
......@@ -15,7 +15,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
......@@ -170,8 +170,9 @@ class ShortcutsBackend : public RefcountedKeyedService,
// This is a helper map for quick access to a shortcut by guid.
GuidMap guid_map_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
history_service_observer_{this};
base::ScopedObservation<history::HistoryService,
history::HistoryServiceObserver>
history_service_observation_{this};
scoped_refptr<base::SequencedTaskRunner> main_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