| 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 "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" |
| 11 #include "sync/notifier/invalidation_notifier.h" | 11 #include "sync/notifier/invalidation_notifier.h" |
| 12 | 12 |
| 13 namespace sync_notifier { | 13 namespace sync_notifier { |
| 14 | 14 |
| 15 class NonBlockingInvalidationNotifier::Core | 15 class NonBlockingInvalidationNotifier::Core |
| 16 : public base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>, | 16 : public base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>, |
| 17 // SyncNotifierObserver to observe the InvalidationNotifier we create. |
| 17 public SyncNotifierObserver { | 18 public SyncNotifierObserver { |
| 18 public: | 19 public: |
| 19 // Called on parent thread. |delegate_observer| should be | 20 // Called on parent thread. |delegate_observer| should be |
| 20 // initialized. | 21 // initialized. |
| 21 explicit Core( | 22 explicit Core( |
| 22 const browser_sync::WeakHandle<SyncNotifierObserver>& | 23 const browser_sync::WeakHandle<SyncNotifierObserver>& |
| 23 delegate_observer); | 24 delegate_observer); |
| 24 | 25 |
| 25 // Helpers called on I/O thread. | 26 // Helpers called on I/O thread. |
| 26 void Initialize( | 27 void Initialize( |
| 27 const notifier::NotifierOptions& notifier_options, | 28 const notifier::NotifierOptions& notifier_options, |
| 28 const InvalidationVersionMap& initial_max_invalidation_versions, | 29 const InvalidationVersionMap& initial_max_invalidation_versions, |
| 29 const browser_sync::WeakHandle<InvalidationStateTracker>& | 30 const browser_sync::WeakHandle<InvalidationStateTracker>& |
| 30 invalidation_state_tracker, | 31 invalidation_state_tracker, |
| 31 const std::string& client_info); | 32 const std::string& client_info); |
| 32 void Teardown(); | 33 void Teardown(); |
| 33 void SetUniqueId(const std::string& unique_id); | 34 void SetUniqueId(const std::string& unique_id); |
| 34 void SetState(const std::string& state); | 35 void SetState(const std::string& state); |
| 35 void UpdateCredentials(const std::string& email, const std::string& token); | 36 void UpdateCredentials(const std::string& email, const std::string& token); |
| 36 void UpdateEnabledTypes(syncable::ModelTypeSet enabled_types); | 37 void UpdateEnabledTypes(syncable::ModelTypeSet enabled_types); |
| 37 | 38 |
| 38 // SyncNotifierObserver implementation (all called on I/O thread). | 39 // SyncNotifierObserver implementation (all called on I/O thread by |
| 40 // InvalidationNotifier). |
| 39 virtual void OnIncomingNotification( | 41 virtual void OnIncomingNotification( |
| 40 const syncable::ModelTypePayloadMap& type_payloads, | 42 const syncable::ModelTypePayloadMap& type_payloads, |
| 41 IncomingNotificationSource source); | 43 IncomingNotificationSource source); |
| 42 virtual void OnNotificationStateChange(bool notifications_enabled); | 44 virtual void OnNotificationStateChange(bool notifications_enabled); |
| 43 virtual void StoreState(const std::string& state); | 45 virtual void StoreState(const std::string& state); |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 friend class | 48 friend class |
| 47 base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>; | 49 base::RefCountedThreadSafe<NonBlockingInvalidationNotifier::Core>; |
| 48 // Called on parent or I/O thread. | 50 // Called on parent or I/O thread. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 261 } |
| 260 | 262 |
| 261 void NonBlockingInvalidationNotifier::StoreState( | 263 void NonBlockingInvalidationNotifier::StoreState( |
| 262 const std::string& state) { | 264 const std::string& state) { |
| 263 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); | 265 DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); |
| 264 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, | 266 FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, |
| 265 StoreState(state)); | 267 StoreState(state)); |
| 266 } | 268 } |
| 267 | 269 |
| 268 } // namespace sync_notifier | 270 } // namespace sync_notifier |
| OLD | NEW |