| OLD | NEW |
| 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 <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 void SetUniqueId(const std::string& unique_id); | 39 void SetUniqueId(const std::string& unique_id); |
| 40 void SetStateDeprecated(const std::string& state); | 40 void SetStateDeprecated(const std::string& state); |
| 41 void UpdateCredentials(const std::string& email, const std::string& token); | 41 void UpdateCredentials(const std::string& email, const std::string& token); |
| 42 | 42 |
| 43 // SyncNotifierObserver implementation (all called on I/O thread by | 43 // SyncNotifierObserver implementation (all called on I/O thread by |
| 44 // InvalidationNotifier). | 44 // InvalidationNotifier). |
| 45 virtual void OnNotificationsEnabled() OVERRIDE; | 45 virtual void OnNotificationsEnabled() OVERRIDE; |
| 46 virtual void OnNotificationsDisabled( | 46 virtual void OnNotificationsDisabled( |
| 47 NotificationsDisabledReason reason) OVERRIDE; | 47 NotificationsDisabledReason reason) OVERRIDE; |
| 48 virtual void OnIncomingNotification( | 48 virtual void OnIncomingNotification( |
| 49 const ObjectIdPayloadMap& id_payloads, | 49 const ObjectIdStateMap& id_state_map, |
| 50 IncomingNotificationSource source) OVERRIDE; | 50 IncomingNotificationSource source) OVERRIDE; |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 friend class | 53 friend class |
| 54 base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>; | 54 base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>; |
| 55 // Called on parent or I/O thread. | 55 // Called on parent or I/O thread. |
| 56 ~Core(); | 56 ~Core(); |
| 57 | 57 |
| 58 // The variables below should be used only on the I/O thread. | 58 // The variables below should be used only on the I/O thread. |
| 59 const WeakHandle<SyncNotifierObserver> delegate_observer_; | 59 const WeakHandle<SyncNotifierObserver> delegate_observer_; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 void NonBlockingInvalidationNotifier::Core::OnNotificationsDisabled( | 134 void NonBlockingInvalidationNotifier::Core::OnNotificationsDisabled( |
| 135 NotificationsDisabledReason reason) { | 135 NotificationsDisabledReason reason) { |
| 136 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 136 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 137 delegate_observer_.Call( | 137 delegate_observer_.Call( |
| 138 FROM_HERE, &SyncNotifierObserver::OnNotificationsDisabled, reason); | 138 FROM_HERE, &SyncNotifierObserver::OnNotificationsDisabled, reason); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void NonBlockingInvalidationNotifier::Core::OnIncomingNotification( | 141 void NonBlockingInvalidationNotifier::Core::OnIncomingNotification( |
| 142 const ObjectIdPayloadMap& id_payloads, IncomingNotificationSource source) { | 142 const ObjectIdStateMap& id_state_map, IncomingNotificationSource source) { |
| 143 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 143 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 144 delegate_observer_.Call(FROM_HERE, | 144 delegate_observer_.Call(FROM_HERE, |
| 145 &SyncNotifierObserver::OnIncomingNotification, | 145 &SyncNotifierObserver::OnIncomingNotification, |
| 146 id_payloads, | 146 id_state_map, |
| 147 source); | 147 source); |
| 148 } | 148 } |
| 149 | 149 |
| 150 NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier( | 150 NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier( |
| 151 const notifier::NotifierOptions& notifier_options, | 151 const notifier::NotifierOptions& notifier_options, |
| 152 const InvalidationVersionMap& initial_max_invalidation_versions, | 152 const InvalidationVersionMap& initial_max_invalidation_versions, |
| 153 const std::string& initial_invalidation_state, | 153 const std::string& initial_invalidation_state, |
| 154 const WeakHandle<InvalidationStateTracker>& | 154 const WeakHandle<InvalidationStateTracker>& |
| 155 invalidation_state_tracker, | 155 invalidation_state_tracker, |
| 156 const std::string& client_info) | 156 const std::string& client_info) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 registrar_.EmitOnNotificationsEnabled(); | 258 registrar_.EmitOnNotificationsEnabled(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void NonBlockingInvalidationNotifier::OnNotificationsDisabled( | 261 void NonBlockingInvalidationNotifier::OnNotificationsDisabled( |
| 262 NotificationsDisabledReason reason) { | 262 NotificationsDisabledReason reason) { |
| 263 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 263 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 264 registrar_.EmitOnNotificationsDisabled(reason); | 264 registrar_.EmitOnNotificationsDisabled(reason); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void NonBlockingInvalidationNotifier::OnIncomingNotification( | 267 void NonBlockingInvalidationNotifier::OnIncomingNotification( |
| 268 const ObjectIdPayloadMap& id_payloads, | 268 const ObjectIdStateMap& id_state_map, |
| 269 IncomingNotificationSource source) { | 269 IncomingNotificationSource source) { |
| 270 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 270 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 271 registrar_.DispatchInvalidationsToHandlers(id_payloads, source); | 271 registrar_.DispatchInvalidationsToHandlers(id_state_map, source); |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace syncer | 274 } // namespace syncer |
| OLD | NEW |