Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(948)

Unified Diff: sync/notifier/p2p_notifier.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work around brittle unit test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/notifier/p2p_notifier.h ('k') | sync/notifier/p2p_notifier_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/p2p_notifier.cc
diff --git a/sync/notifier/p2p_notifier.cc b/sync/notifier/p2p_notifier.cc
index 5d5aeffc04bd33bdd50a1251e96620ff928d4794..dab7221955afd7fce5c002cc45f74069af895e92 100644
--- a/sync/notifier/p2p_notifier.cc
+++ b/sync/notifier/p2p_notifier.cc
@@ -157,10 +157,18 @@ P2PNotifier::~P2PNotifier() {
push_client_->RemoveObserver(this);
}
+void P2PNotifier::RegisterHandler(SyncNotifierObserver* handler) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ registrar_.RegisterHandler(handler);
+}
+
void P2PNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler,
const ObjectIdSet& ids) {
- const ModelTypeSet enabled_types = ObjectIdSetToModelTypeSet(
- helper_.UpdateRegisteredIds(handler, ids));
+ // TODO(akalin): Handle arbitrary object IDs (http://crbug.com/140411).
+ DCHECK(thread_checker_.CalledOnValidThread());
+ registrar_.UpdateRegisteredIds(handler, ids);
+ const ModelTypeSet enabled_types =
+ ObjectIdSetToModelTypeSet(registrar_.GetAllRegisteredIds());
const ModelTypeSet new_enabled_types =
Difference(enabled_types, enabled_types_);
const P2PNotificationData notification_data(
@@ -169,6 +177,11 @@ void P2PNotifier::UpdateRegisteredIds(SyncNotifierObserver* handler,
enabled_types_ = enabled_types;
}
+void P2PNotifier::UnregisterHandler(SyncNotifierObserver* handler) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ registrar_.UnregisterHandler(handler);
+}
+
void P2PNotifier::SetUniqueId(const std::string& unique_id) {
DCHECK(thread_checker_.CalledOnValidThread());
unique_id_ = unique_id;
@@ -207,7 +220,7 @@ void P2PNotifier::OnNotificationsEnabled() {
DCHECK(thread_checker_.CalledOnValidThread());
bool just_turned_on = (notifications_enabled_ == false);
notifications_enabled_ = true;
- helper_.EmitOnNotificationsEnabled();
+ registrar_.EmitOnNotificationsEnabled();
if (just_turned_on) {
const P2PNotificationData notification_data(
unique_id_, NOTIFY_SELF, enabled_types_);
@@ -218,7 +231,7 @@ void P2PNotifier::OnNotificationsEnabled() {
void P2PNotifier::OnNotificationsDisabled(
notifier::NotificationsDisabledReason reason) {
DCHECK(thread_checker_.CalledOnValidThread());
- helper_.EmitOnNotificationsDisabled(FromNotifierReason(reason));
+ registrar_.EmitOnNotificationsDisabled(FromNotifierReason(reason));
}
void P2PNotifier::OnIncomingNotification(
@@ -257,7 +270,7 @@ void P2PNotifier::OnIncomingNotification(
}
const ModelTypePayloadMap& type_payloads = ModelTypePayloadMapFromEnumSet(
notification_data.GetChangedTypes(), std::string());
- helper_.DispatchInvalidationsToHandlers(
+ registrar_.DispatchInvalidationsToHandlers(
ModelTypePayloadMapToObjectIdPayloadMap(type_payloads),
REMOTE_NOTIFICATION);
}
« no previous file with comments | « sync/notifier/p2p_notifier.h ('k') | sync/notifier/p2p_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698