Commit 905887d7 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

PM: Migrate away from ScopedObserver.

This moves users of ScopedObserver to either base::ScopedObservation
or base::ScopedMultiSourceObservation in the performance_manager.

Bug: 1145565
Change-Id: Ide766fc0139134ebc6f9cdfff58864fccb1b78f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2520246
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Reviewed-by: default avatarSébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: default avatarPatrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824563}
parent 3eeaae12
...@@ -195,7 +195,7 @@ void ChromeBrowserMainExtraPartsPerformanceManager::PostMainMessageLoopRun() { ...@@ -195,7 +195,7 @@ void ChromeBrowserMainExtraPartsPerformanceManager::PostMainMessageLoopRun() {
browser_child_process_watcher_.reset(); browser_child_process_watcher_.reset();
g_browser_process->profile_manager()->RemoveObserver(this); g_browser_process->profile_manager()->RemoveObserver(this);
observed_profiles_.RemoveAll(); profile_observations_.RemoveAllObservations();
page_load_tracker_decorator_helper_.reset(); page_load_tracker_decorator_helper_.reset();
page_live_state_data_helper_.reset(); page_live_state_data_helper_.reset();
...@@ -214,7 +214,7 @@ void ChromeBrowserMainExtraPartsPerformanceManager::PostMainMessageLoopRun() { ...@@ -214,7 +214,7 @@ void ChromeBrowserMainExtraPartsPerformanceManager::PostMainMessageLoopRun() {
void ChromeBrowserMainExtraPartsPerformanceManager::OnProfileAdded( void ChromeBrowserMainExtraPartsPerformanceManager::OnProfileAdded(
Profile* profile) { Profile* profile) {
observed_profiles_.Add(profile); profile_observations_.AddObservation(profile);
registry_->NotifyBrowserContextAdded(profile); registry_->NotifyBrowserContextAdded(profile);
} }
...@@ -225,6 +225,6 @@ void ChromeBrowserMainExtraPartsPerformanceManager:: ...@@ -225,6 +225,6 @@ void ChromeBrowserMainExtraPartsPerformanceManager::
void ChromeBrowserMainExtraPartsPerformanceManager::OnProfileWillBeDestroyed( void ChromeBrowserMainExtraPartsPerformanceManager::OnProfileWillBeDestroyed(
Profile* profile) { Profile* profile) {
observed_profiles_.Remove(profile); profile_observations_.RemoveObservation(profile);
registry_->NotifyBrowserContextRemoved(profile); registry_->NotifyBrowserContextRemoved(profile);
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_multi_source_observation.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h" #include "chrome/browser/chrome_browser_main_extra_parts.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager_observer.h" #include "chrome/browser/profiles/profile_manager_observer.h"
...@@ -76,7 +76,8 @@ class ChromeBrowserMainExtraPartsPerformanceManager ...@@ -76,7 +76,8 @@ class ChromeBrowserMainExtraPartsPerformanceManager
std::unique_ptr<performance_manager::BrowserChildProcessWatcher> std::unique_ptr<performance_manager::BrowserChildProcessWatcher>
browser_child_process_watcher_; browser_child_process_watcher_;
ScopedObserver<Profile, ProfileObserver> observed_profiles_{this}; base::ScopedMultiSourceObservation<Profile, ProfileObserver>
profile_observations_{this};
// Needed to record "Pageloads" metrics. // Needed to record "Pageloads" metrics.
std::unique_ptr<performance_manager::PageLoadMetricsObserver> std::unique_ptr<performance_manager::PageLoadMetricsObserver>
......
...@@ -50,7 +50,7 @@ SiteDataCacheFacade::SiteDataCacheFacade( ...@@ -50,7 +50,7 @@ SiteDataCacheFacade::SiteDataCacheFacade(
HistoryServiceFactory::GetForProfileWithoutCreating( HistoryServiceFactory::GetForProfileWithoutCreating(
Profile::FromBrowserContext(browser_context_)); Profile::FromBrowserContext(browser_context_));
if (history) if (history)
history_observer_.Add(history); history_observation_.Observe(history);
} }
SiteDataCacheFacade::~SiteDataCacheFacade() { SiteDataCacheFacade::~SiteDataCacheFacade() {
...@@ -154,7 +154,8 @@ void SiteDataCacheFacade::OnURLsDeleted( ...@@ -154,7 +154,8 @@ void SiteDataCacheFacade::OnURLsDeleted(
void SiteDataCacheFacade::HistoryServiceBeingDeleted( void SiteDataCacheFacade::HistoryServiceBeingDeleted(
history::HistoryService* history_service) { history::HistoryService* history_service) {
history_observer_.Remove(history_service); DCHECK(history_observation_.IsObservingSource(history_service));
history_observation_.RemoveObservation();
} }
} // namespace performance_manager } // namespace performance_manager
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "components/history/core/browser/history_service.h" #include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_service_observer.h" #include "components/history/core/browser/history_service_observer.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
...@@ -43,8 +43,9 @@ class SiteDataCacheFacade : public KeyedService, ...@@ -43,8 +43,9 @@ class SiteDataCacheFacade : public KeyedService,
// The browser context associated with this cache. // The browser context associated with this cache.
content::BrowserContext* browser_context_; content::BrowserContext* browser_context_;
ScopedObserver<history::HistoryService, history::HistoryServiceObserver> base::ScopedObservation<history::HistoryService,
history_observer_{this}; history::HistoryServiceObserver>
history_observation_{this};
DISALLOW_COPY_AND_ASSIGN(SiteDataCacheFacade); DISALLOW_COPY_AND_ASSIGN(SiteDataCacheFacade);
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/check_op.h" #include "base/check_op.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/scoped_observation.h" #include "base/scoped_observer.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/render_process_host_observer.h"
...@@ -82,7 +82,7 @@ void ServiceWorkerContextAdapter::RunningServiceWorker:: ...@@ -82,7 +82,7 @@ void ServiceWorkerContextAdapter::RunningServiceWorker::
ServiceWorkerContextAdapter::ServiceWorkerContextAdapter( ServiceWorkerContextAdapter::ServiceWorkerContextAdapter(
content::ServiceWorkerContext* underlying_context) { content::ServiceWorkerContext* underlying_context) {
scoped_underlying_context_observer_.Add(underlying_context); scoped_underlying_context_observation_.Observe(underlying_context);
} }
ServiceWorkerContextAdapter::~ServiceWorkerContextAdapter() { ServiceWorkerContextAdapter::~ServiceWorkerContextAdapter() {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "content/public/browser/service_worker_context.h" #include "content/public/browser/service_worker_context.h"
#include "content/public/browser/service_worker_context_observer.h" #include "content/public/browser/service_worker_context_observer.h"
...@@ -132,9 +132,9 @@ class ServiceWorkerContextAdapter ...@@ -132,9 +132,9 @@ class ServiceWorkerContextAdapter
// returns true if a registration existed, false otherwise. // returns true if a registration existed, false otherwise.
bool MaybeRemoveRunningServiceWorker(int64_t version_id); bool MaybeRemoveRunningServiceWorker(int64_t version_id);
ScopedObserver<content::ServiceWorkerContext, base::ScopedObservation<content::ServiceWorkerContext,
content::ServiceWorkerContextObserver> content::ServiceWorkerContextObserver>
scoped_underlying_context_observer_{this}; scoped_underlying_context_observation_{this};
base::ObserverList<content::ServiceWorkerContextObserver, true, false>:: base::ObserverList<content::ServiceWorkerContextObserver, true, false>::
Unchecked observer_list_; Unchecked observer_list_;
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
namespace performance_manager { namespace performance_manager {
TabHelperFrameNodeSource::TabHelperFrameNodeSource() TabHelperFrameNodeSource::TabHelperFrameNodeSource()
: performance_manager_tab_helper_observers_(this) {} : performance_manager_tab_helper_observations_(this) {}
TabHelperFrameNodeSource::~TabHelperFrameNodeSource() { TabHelperFrameNodeSource::~TabHelperFrameNodeSource() {
DCHECK(observed_frame_nodes_.empty()); DCHECK(observed_frame_nodes_.empty());
DCHECK(!performance_manager_tab_helper_observers_.IsObservingSources()); DCHECK(!performance_manager_tab_helper_observations_.IsObservingAnySource());
} }
FrameNodeImpl* TabHelperFrameNodeSource::GetFrameNode( FrameNodeImpl* TabHelperFrameNodeSource::GetFrameNode(
...@@ -57,7 +57,7 @@ void TabHelperFrameNodeSource::SubscribeToFrameNode( ...@@ -57,7 +57,7 @@ void TabHelperFrameNodeSource::SubscribeToFrameNode(
if (AddObservedFrameNode(performance_manager_tab_helper, frame_node)) { if (AddObservedFrameNode(performance_manager_tab_helper, frame_node)) {
// Start observing the tab helper only if this is the first observed frame // Start observing the tab helper only if this is the first observed frame
// that is associated with it. // that is associated with it.
performance_manager_tab_helper_observers_.Add( performance_manager_tab_helper_observations_.AddObservation(
performance_manager_tab_helper); performance_manager_tab_helper);
} }
...@@ -93,7 +93,7 @@ void TabHelperFrameNodeSource::UnsubscribeFromFrameNode( ...@@ -93,7 +93,7 @@ void TabHelperFrameNodeSource::UnsubscribeFromFrameNode(
if (RemoveObservedFrameNode(performance_manager_tab_helper, frame_node)) { if (RemoveObservedFrameNode(performance_manager_tab_helper, frame_node)) {
// Stop observing that tab helper if there no longer are any observed // Stop observing that tab helper if there no longer are any observed
// frames that are associated with it. // frames that are associated with it.
performance_manager_tab_helper_observers_.Remove( performance_manager_tab_helper_observations_.RemoveObservation(
performance_manager_tab_helper); performance_manager_tab_helper);
} }
} }
...@@ -116,7 +116,7 @@ void TabHelperFrameNodeSource::OnBeforeFrameNodeRemoved( ...@@ -116,7 +116,7 @@ void TabHelperFrameNodeSource::OnBeforeFrameNodeRemoved(
if (RemoveObservedFrameNode(performance_manager_tab_helper, frame_node)) { if (RemoveObservedFrameNode(performance_manager_tab_helper, frame_node)) {
// Stop observing that tab helper if there no longer are any observed // Stop observing that tab helper if there no longer are any observed
// frames that are associated with it. // frames that are associated with it.
performance_manager_tab_helper_observers_.Remove( performance_manager_tab_helper_observations_.RemoveObservation(
performance_manager_tab_helper); performance_manager_tab_helper);
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/observer_list_types.h" #include "base/observer_list_types.h"
#include "base/scoped_observer.h" #include "base/scoped_multi_source_observation.h"
#include "components/performance_manager/performance_manager_tab_helper.h" #include "components/performance_manager/performance_manager_tab_helper.h"
namespace performance_manager { namespace performance_manager {
...@@ -63,9 +63,9 @@ class TabHelperFrameNodeSource : public FrameNodeSource, ...@@ -63,9 +63,9 @@ class TabHelperFrameNodeSource : public FrameNodeSource,
observed_frame_nodes_; observed_frame_nodes_;
// Observes frame node deletions. // Observes frame node deletions.
ScopedObserver<PerformanceManagerTabHelper, base::ScopedMultiSourceObservation<PerformanceManagerTabHelper,
PerformanceManagerTabHelper::Observer> PerformanceManagerTabHelper::Observer>
performance_manager_tab_helper_observers_; performance_manager_tab_helper_observations_;
DISALLOW_COPY_AND_ASSIGN(TabHelperFrameNodeSource); DISALLOW_COPY_AND_ASSIGN(TabHelperFrameNodeSource);
}; };
......
...@@ -121,20 +121,20 @@ WorkerWatcher::WorkerWatcher( ...@@ -121,20 +121,20 @@ WorkerWatcher::WorkerWatcher(
DCHECK(process_node_source_); DCHECK(process_node_source_);
DCHECK(frame_node_source_); DCHECK(frame_node_source_);
dedicated_worker_service_observer_.Add(dedicated_worker_service); dedicated_worker_service_observation_.Observe(dedicated_worker_service);
shared_worker_service_observer_.Add(shared_worker_service); shared_worker_service_observation_.Observe(shared_worker_service);
service_worker_context_observer_.Add(service_worker_context); service_worker_context_observation_.Observe(service_worker_context);
} }
WorkerWatcher::~WorkerWatcher() { WorkerWatcher::~WorkerWatcher() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(frame_node_child_workers_.empty()); DCHECK(frame_node_child_workers_.empty());
DCHECK(dedicated_worker_nodes_.empty()); DCHECK(dedicated_worker_nodes_.empty());
DCHECK(!dedicated_worker_service_observer_.IsObservingSources()); DCHECK(!dedicated_worker_service_observation_.IsObserving());
DCHECK(shared_worker_nodes_.empty()); DCHECK(shared_worker_nodes_.empty());
DCHECK(!shared_worker_service_observer_.IsObservingSources()); DCHECK(!shared_worker_service_observation_.IsObserving());
DCHECK(service_worker_nodes_.empty()); DCHECK(service_worker_nodes_.empty());
DCHECK(!service_worker_context_observer_.IsObservingSources()); DCHECK(!service_worker_context_observation_.IsObserving());
} }
void WorkerWatcher::TearDown() { void WorkerWatcher::TearDown() {
...@@ -201,9 +201,9 @@ void WorkerWatcher::TearDown() { ...@@ -201,9 +201,9 @@ void WorkerWatcher::TearDown() {
PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes)); PerformanceManagerImpl::BatchDeleteNodes(std::move(nodes));
dedicated_worker_service_observer_.RemoveAll(); dedicated_worker_service_observation_.RemoveObservation();
shared_worker_service_observer_.RemoveAll(); shared_worker_service_observation_.RemoveObservation();
service_worker_context_observer_.RemoveAll(); service_worker_context_observation_.RemoveObservation();
} }
void WorkerWatcher::OnWorkerCreated( void WorkerWatcher::OnWorkerCreated(
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/scoped_observer.h" #include "base/scoped_observation.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "components/performance_manager/service_worker_client.h" #include "components/performance_manager/service_worker_client.h"
#include "content/public/browser/dedicated_worker_service.h" #include "content/public/browser/dedicated_worker_service.h"
...@@ -177,18 +177,18 @@ class WorkerWatcher : public content::DedicatedWorkerService::Observer, ...@@ -177,18 +177,18 @@ class WorkerWatcher : public content::DedicatedWorkerService::Observer,
const std::string browser_context_id_; const std::string browser_context_id_;
// Observes the DedicatedWorkerService for this browser context. // Observes the DedicatedWorkerService for this browser context.
ScopedObserver<content::DedicatedWorkerService, base::ScopedObservation<content::DedicatedWorkerService,
content::DedicatedWorkerService::Observer> content::DedicatedWorkerService::Observer>
dedicated_worker_service_observer_{this}; dedicated_worker_service_observation_{this};
// Observes the SharedWorkerService for this browser context. // Observes the SharedWorkerService for this browser context.
ScopedObserver<content::SharedWorkerService, base::ScopedObservation<content::SharedWorkerService,
content::SharedWorkerService::Observer> content::SharedWorkerService::Observer>
shared_worker_service_observer_{this}; shared_worker_service_observation_{this};
ScopedObserver<content::ServiceWorkerContext, base::ScopedObservation<content::ServiceWorkerContext,
content::ServiceWorkerContextObserver> content::ServiceWorkerContextObserver>
service_worker_context_observer_{this}; service_worker_context_observation_{this};
// Used to retrieve an existing process node from its render process ID. // Used to retrieve an existing process node from its render process ID.
ProcessNodeSource* const process_node_source_; ProcessNodeSource* const process_node_source_;
......
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