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

Unified Diff: sync/notifier/p2p_notifier.cc

Issue 10545170: [Sync] Propagate XMPP auth errors to SyncNotifierObservers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix deps, win compile error Created 8 years, 6 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
Index: sync/notifier/p2p_notifier.cc
diff --git a/sync/notifier/p2p_notifier.cc b/sync/notifier/p2p_notifier.cc
index 2eae2465b9a828028bb3c54e8cdfc928c2f553b4..211cb2afab56e82ee438841396d6f75da25825a2 100644
--- a/sync/notifier/p2p_notifier.cc
+++ b/sync/notifier/p2p_notifier.cc
@@ -212,19 +212,28 @@ void P2PNotifier::SendNotification(
SendNotificationData(notification_data);
}
-void P2PNotifier::OnNotificationStateChange(bool notifications_enabled) {
+void P2PNotifier::OnNotificationsEnabled() {
DCHECK(non_thread_safe_.CalledOnValidThread());
- bool disabled_to_enabled = notifications_enabled && !notifications_enabled_;
- notifications_enabled_ = notifications_enabled;
- FOR_EACH_OBSERVER(SyncNotifierObserver, observer_list_,
- OnNotificationStateChange(notifications_enabled_));
- if (disabled_to_enabled) {
+ bool just_turned_on = (notifications_enabled_ == false);
+ notifications_enabled_ = true;
+ FOR_EACH_OBSERVER(
+ SyncNotifierObserver, observer_list_,
+ OnNotificationsEnabled());
+ if (just_turned_on) {
const P2PNotificationData notification_data(
unique_id_, NOTIFY_SELF, enabled_types_);
SendNotificationData(notification_data);
}
}
+void P2PNotifier::OnNotificationsDisabled(
+ notifier::NotificationsDisabledReason reason) {
+ DCHECK(non_thread_safe_.CalledOnValidThread());
+ FOR_EACH_OBSERVER(
+ SyncNotifierObserver, observer_list_,
+ OnNotificationsDisabled(FromNotifierReason(reason)));
+}
+
void P2PNotifier::OnIncomingNotification(
const notifier::Notification& notification) {
DCHECK(non_thread_safe_.CalledOnValidThread());
@@ -234,7 +243,7 @@ void P2PNotifier::OnIncomingNotification(
return;
}
if (!notifications_enabled_) {
- DVLOG(1) << "Notifications not enabled -- not emitting notification";
+ DVLOG(1) << "Notifications not on -- not emitting notification";
return;
}
if (notification.channel != kSyncP2PNotificationChannel) {

Powered by Google App Engine
This is Rietveld 408576698