Commit 8e504e42 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /components/sync.

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=rushans@google.com

Bug: 1145565
Change-Id: I760ad7d03410e304b00db5497fb44120e9768fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532959
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Reviewed-by: default avatarRushan Suleymanov <rushans@google.com>
Cr-Commit-Position: refs/heads/master@{#827855}
parent eaff997c
......@@ -30,9 +30,9 @@ SyncSessionDurationsMetricsRecorder::SyncSessionDurationsMetricsRecorder(
: sync_service_(sync_service), identity_manager_(identity_manager) {
// |sync_service| can be null if sync is disabled by a command line flag.
if (sync_service_) {
sync_observer_.Add(sync_service_);
sync_observation_.Observe(sync_service_);
}
identity_manager_observer_.Add(identity_manager_);
identity_manager_observation_.Observe(identity_manager_);
// Since this is created after the profile itself is created, we need to
// handle the initial state.
......@@ -52,8 +52,9 @@ SyncSessionDurationsMetricsRecorder::SyncSessionDurationsMetricsRecorder(
SyncSessionDurationsMetricsRecorder::~SyncSessionDurationsMetricsRecorder() {
DCHECK(!total_session_timer_) << "Missing a call to OnSessionEnded().";
sync_observer_.RemoveAll();
identity_manager_observer_.RemoveAll();
if (sync_observation_.IsObserving())
sync_observation_.RemoveObservation();
identity_manager_observation_.RemoveObservation();
}
void SyncSessionDurationsMetricsRecorder::OnSessionStarted(
......
......@@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include "base/scoped_observer.h"
#include "base/scoped_observation.h"
#include "base/timer/elapsed_timer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
......@@ -74,10 +74,11 @@ class SyncSessionDurationsMetricsRecorder
SyncService* const sync_service_;
signin::IdentityManager* const identity_manager_;
ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
sync_observer_{this};
ScopedObserver<signin::IdentityManager, signin::IdentityManager::Observer>
identity_manager_observer_{this};
base::ScopedObservation<syncer::SyncService, syncer::SyncServiceObserver>
sync_observation_{this};
base::ScopedObservation<signin::IdentityManager,
signin::IdentityManager::Observer>
identity_manager_observation_{this};
// Tracks the elapsed active session time while the browser is open. The timer
// is absent if there's no active session.
......
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