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