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

Side by Side Diff: jingle/notifier/listener/xmpp_push_client.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "jingle/notifier/listener/xmpp_push_client.h" 5 #include "jingle/notifier/listener/xmpp_push_client.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "jingle/notifier/base/notifier_options_util.h" 9 #include "jingle/notifier/base/notifier_options_util.h"
10 #include "jingle/notifier/listener/push_client_observer.h" 10 #include "jingle/notifier/listener/push_client_observer.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 std::vector<Notification> notifications_to_send; 51 std::vector<Notification> notifications_to_send;
52 notifications_to_send.swap(pending_notifications_to_send_); 52 notifications_to_send.swap(pending_notifications_to_send_);
53 for (std::vector<Notification>::const_iterator it = 53 for (std::vector<Notification>::const_iterator it =
54 notifications_to_send.begin(); 54 notifications_to_send.begin();
55 it != notifications_to_send.end(); ++it) { 55 it != notifications_to_send.end(); ++it) {
56 DVLOG(1) << "Push: Sending pending notification " << it->ToString(); 56 DVLOG(1) << "Push: Sending pending notification " << it->ToString();
57 SendNotification(*it); 57 SendNotification(*it);
58 } 58 }
59 } 59 }
60 60
61 void XmppPushClient::OnDisconnect() { 61 void XmppPushClient::OnTransientDisconnection() {
62 DCHECK(non_thread_safe_.CalledOnValidThread()); 62 DCHECK(non_thread_safe_.CalledOnValidThread());
63 base_task_.reset(); 63 base_task_.reset();
64 FOR_EACH_OBSERVER(PushClientObserver, observers_, 64 FOR_EACH_OBSERVER(PushClientObserver, observers_,
65 OnNotificationStateChange(false)); 65 OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR));
66 }
67
68 void XmppPushClient::OnCredentialsRejected() {
69 DCHECK(non_thread_safe_.CalledOnValidThread());
70 base_task_.reset();
71 FOR_EACH_OBSERVER(
72 PushClientObserver, observers_,
73 OnNotificationsDisabled(NOTIFICATION_CREDENTIALS_REJECTED));
66 } 74 }
67 75
68 void XmppPushClient::OnNotificationReceived( 76 void XmppPushClient::OnNotificationReceived(
69 const Notification& notification) { 77 const Notification& notification) {
70 DCHECK(non_thread_safe_.CalledOnValidThread()); 78 DCHECK(non_thread_safe_.CalledOnValidThread());
71 FOR_EACH_OBSERVER(PushClientObserver, observers_, 79 FOR_EACH_OBSERVER(PushClientObserver, observers_,
72 OnIncomingNotification(notification)); 80 OnIncomingNotification(notification));
73 } 81 }
74 82
75 void XmppPushClient::OnSubscribed() { 83 void XmppPushClient::OnSubscribed() {
76 DCHECK(non_thread_safe_.CalledOnValidThread()); 84 DCHECK(non_thread_safe_.CalledOnValidThread());
77 FOR_EACH_OBSERVER(PushClientObserver, observers_, 85 FOR_EACH_OBSERVER(PushClientObserver, observers_,
78 OnNotificationStateChange(true)); 86 OnNotificationsEnabled());
79 } 87 }
80 88
81 void XmppPushClient::OnSubscriptionError() { 89 void XmppPushClient::OnSubscriptionError() {
82 DCHECK(non_thread_safe_.CalledOnValidThread()); 90 DCHECK(non_thread_safe_.CalledOnValidThread());
83 FOR_EACH_OBSERVER(PushClientObserver, observers_, 91 FOR_EACH_OBSERVER(PushClientObserver, observers_,
84 OnNotificationStateChange(false)); 92 OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR));
85 } 93 }
86 94
87 void XmppPushClient::AddObserver(PushClientObserver* observer) { 95 void XmppPushClient::AddObserver(PushClientObserver* observer) {
88 DCHECK(non_thread_safe_.CalledOnValidThread()); 96 DCHECK(non_thread_safe_.CalledOnValidThread());
89 observers_.AddObserver(observer); 97 observers_.AddObserver(observer);
90 } 98 }
91 99
92 void XmppPushClient::RemoveObserver(PushClientObserver* observer) { 100 void XmppPushClient::RemoveObserver(PushClientObserver* observer) {
93 DCHECK(non_thread_safe_.CalledOnValidThread()); 101 DCHECK(non_thread_safe_.CalledOnValidThread());
94 observers_.RemoveObserver(observer); 102 observers_.RemoveObserver(observer);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 pending_notifications_to_send_.push_back(notification); 137 pending_notifications_to_send_.push_back(notification);
130 return; 138 return;
131 } 139 }
132 // Owned by |base_task_|. 140 // Owned by |base_task_|.
133 PushNotificationsSendUpdateTask* task = 141 PushNotificationsSendUpdateTask* task =
134 new PushNotificationsSendUpdateTask(base_task_, notification); 142 new PushNotificationsSendUpdateTask(base_task_, notification);
135 task->Start(); 143 task->Start();
136 } 144 }
137 145
138 } // namespace notifier 146 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698