Commit 3a22fedf authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Commit Bot

Retire ScopedObserver in /components/ukm.

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

Bug: 1145565
Change-Id: I7abefcdf0a512108ecd78ff910f59b9c116db74d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533173
Commit-Queue: Brian White <bcwhite@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Auto-Submit: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826414}
parent 351aae25
......@@ -13,7 +13,7 @@ HistoryDeleteObserver::~HistoryDeleteObserver() {}
void HistoryDeleteObserver::ObserveServiceForDeletions(
history::HistoryService* history_service) {
if (history_service)
history_observer_.Add(history_service);
history_observations_.AddObservation(history_service);
}
void HistoryDeleteObserver::OnURLsDeleted(
......@@ -25,7 +25,7 @@ void HistoryDeleteObserver::OnURLsDeleted(
void HistoryDeleteObserver::HistoryServiceBeingDeleted(
history::HistoryService* history_service) {
history_observer_.Remove(history_service);
history_observations_.RemoveObservation(history_service);
}
} // namespace ukm
......@@ -7,7 +7,7 @@
#include <set>
#include "base/scoped_observer.h"
#include "base/scoped_multi_source_observation.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/history_service_observer.h"
......@@ -34,8 +34,9 @@ class HistoryDeleteObserver : public history::HistoryServiceObserver {
private:
// Tracks observed history services, for cleanup.
ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
history_observer_{this};
base::ScopedMultiSourceObservation<history::HistoryService,
history::HistoryServiceObserver>
history_observations_{this};
DISALLOW_COPY_AND_ASSIGN(HistoryDeleteObserver);
};
......
......@@ -18,7 +18,7 @@ using unified_consent::UrlKeyedDataCollectionConsentHelper;
namespace ukm {
UkmConsentStateObserver::UkmConsentStateObserver() : sync_observer_(this) {}
UkmConsentStateObserver::UkmConsentStateObserver() = default;
UkmConsentStateObserver::~UkmConsentStateObserver() {
for (const auto& entry : consent_helpers_) {
......@@ -55,7 +55,7 @@ void UkmConsentStateObserver::StartObserving(syncer::SyncService* sync_service,
consent_helper->AddObserver(this);
consent_helpers_[sync_service] = std::move(consent_helper);
sync_observer_.Add(sync_service);
sync_observations_.AddObservation(sync_service);
UpdateUkmAllowedForAllProfiles(false);
}
......@@ -149,7 +149,8 @@ void UkmConsentStateObserver::OnSyncShutdown(syncer::SyncService* sync) {
found->second->RemoveObserver(this);
consent_helpers_.erase(found);
}
sync_observer_.Remove(sync);
DCHECK(sync_observations_.IsObservingSource(sync));
sync_observations_.RemoveObservation(sync);
previous_states_.erase(sync);
UpdateUkmAllowedForAllProfiles(/*must_purge=*/false);
}
......
......@@ -7,7 +7,7 @@
#include <map>
#include "base/scoped_observer.h"
#include "base/scoped_multi_source_observation.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_service_observer.h"
#include "components/unified_consent/url_keyed_data_collection_consent_helper.h"
......@@ -69,8 +69,9 @@ class UkmConsentStateObserver
bool CheckPreviousStatesAllowExtensionUkm();
// Tracks observed sync services, for cleanup.
ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
sync_observer_;
base::ScopedMultiSourceObservation<syncer::SyncService,
syncer::SyncServiceObserver>
sync_observations_{this};
// State data about profiles that we need to remember.
struct ProfileState {
......
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