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

Side by Side Diff: sync/notifier/non_blocking_invalidation_notifier.cc

Issue 10545170: [Sync] Propagate XMPP auth errors to SyncNotifierObservers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 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 "sync/notifier/non_blocking_invalidation_notifier.h" 5 #include "sync/notifier/non_blocking_invalidation_notifier.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 25 matching lines...) Expand all
36 void SetUniqueId(const std::string& unique_id); 36 void SetUniqueId(const std::string& unique_id);
37 void SetStateDeprecated(const std::string& state); 37 void SetStateDeprecated(const std::string& state);
38 void UpdateCredentials(const std::string& email, const std::string& token); 38 void UpdateCredentials(const std::string& email, const std::string& token);
39 void UpdateEnabledTypes(syncable::ModelTypeSet enabled_types); 39 void UpdateEnabledTypes(syncable::ModelTypeSet enabled_types);
40 40
41 // SyncNotifierObserver implementation (all called on I/O thread by 41 // SyncNotifierObserver implementation (all called on I/O thread by
42 // InvalidationNotifier). 42 // InvalidationNotifier).
43 virtual void OnIncomingNotification( 43 virtual void OnIncomingNotification(
44 const syncable::ModelTypePayloadMap& type_payloads, 44 const syncable::ModelTypePayloadMap& type_payloads,
45 IncomingNotificationSource source); 45 IncomingNotificationSource source);
46 virtual void OnNotificationStateChange(bool notifications_enabled); 46 virtual void OnSyncNotifierStateChange(
47 SyncNotifierState sync_notifier_state);
47 48
48 private: 49 private:
49 friend class 50 friend class
50 base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>; 51 base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>;
51 // Called on parent or I/O thread. 52 // Called on parent or I/O thread.
52 ~Core(); 53 ~Core();
53 54
54 // The variables below should be used only on the I/O thread. 55 // The variables below should be used only on the I/O thread.
55 const browser_sync::WeakHandle<SyncNotifierObserver> delegate_observer_; 56 const browser_sync::WeakHandle<SyncNotifierObserver> delegate_observer_;
56 scoped_ptr<InvalidationNotifier> invalidation_notifier_; 57 scoped_ptr<InvalidationNotifier> invalidation_notifier_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 invalidation_notifier_->UpdateCredentials(email, token); 119 invalidation_notifier_->UpdateCredentials(email, token);
119 } 120 }
120 121
121 void NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes( 122 void NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes(
122 syncable::ModelTypeSet enabled_types) { 123 syncable::ModelTypeSet enabled_types) {
123 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 124 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
124 invalidation_notifier_->UpdateEnabledTypes(enabled_types); 125 invalidation_notifier_->UpdateEnabledTypes(enabled_types);
125 } 126 }
126 127
127 void NonBlockingInvalidationNotifier::Core::OnIncomingNotification( 128 void NonBlockingInvalidationNotifier::Core::OnIncomingNotification(
128 const syncable::ModelTypePayloadMap& type_payloads, 129 const syncable::ModelTypePayloadMap& type_payloads,
129 IncomingNotificationSource source) { 130 IncomingNotificationSource source) {
130 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 131 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
131 delegate_observer_.Call(FROM_HERE, 132 delegate_observer_.Call(FROM_HERE,
132 &SyncNotifierObserver::OnIncomingNotification, 133 &SyncNotifierObserver::OnIncomingNotification,
133 type_payloads, 134 type_payloads,
134 source); 135 source);
135 } 136 }
136 137
137 void NonBlockingInvalidationNotifier::Core::OnNotificationStateChange( 138 void NonBlockingInvalidationNotifier::Core::OnSyncNotifierStateChange(
138 bool notifications_enabled) { 139 SyncNotifierState sync_notifier_state) {
139 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 140 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
140 delegate_observer_.Call(FROM_HERE, 141 delegate_observer_.Call(FROM_HERE,
141 &SyncNotifierObserver::OnNotificationStateChange, 142 &SyncNotifierObserver::OnSyncNotifierStateChange,
142 notifications_enabled); 143 sync_notifier_state);
143 } 144 }
144 145
145 NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier( 146 NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier(
146 const notifier::NotifierOptions& notifier_options, 147 const notifier::NotifierOptions& notifier_options,
147 const InvalidationVersionMap& initial_max_invalidation_versions, 148 const InvalidationVersionMap& initial_max_invalidation_versions,
148 const std::string& initial_invalidation_state, 149 const std::string& initial_invalidation_state,
149 const browser_sync::WeakHandle<InvalidationStateTracker>& 150 const browser_sync::WeakHandle<InvalidationStateTracker>&
150 invalidation_state_tracker, 151 invalidation_state_tracker,
151 const std::string& client_info) 152 const std::string& client_info)
152 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 153 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 247 }
247 248
248 void NonBlockingInvalidationNotifier::OnIncomingNotification( 249 void NonBlockingInvalidationNotifier::OnIncomingNotification(
249 const syncable::ModelTypePayloadMap& type_payloads, 250 const syncable::ModelTypePayloadMap& type_payloads,
250 IncomingNotificationSource source) { 251 IncomingNotificationSource source) {
251 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); 252 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
252 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, 253 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_,
253 OnIncomingNotification(type_payloads, source)); 254 OnIncomingNotification(type_payloads, source));
254 } 255 }
255 256
256 void NonBlockingInvalidationNotifier::OnNotificationStateChange( 257 void NonBlockingInvalidationNotifier::OnSyncNotifierStateChange(
257 bool notifications_enabled) { 258 SyncNotifierState sync_notifier_state) {
258 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); 259 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
259 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, 260 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_,
260 OnNotificationStateChange(notifications_enabled)); 261 OnSyncNotifierStateChange(sync_notifier_state));
261 } 262 }
262 263
263 } // namespace sync_notifier 264 } // namespace sync_notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698