| 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 // An implementation of SyncNotifier that wraps InvalidationNotifier | 5 // An implementation of SyncNotifier that wraps InvalidationNotifier |
| 6 // on its own thread. | 6 // on its own thread. |
| 7 | 7 |
| 8 #ifndef SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_ | 8 #ifndef SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_ |
| 9 #define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_ | 9 #define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_ |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class NonBlockingInvalidationNotifier | 30 class NonBlockingInvalidationNotifier |
| 31 : public SyncNotifier, | 31 : public SyncNotifier, |
| 32 // SyncNotifierObserver to "observe" our Core via WeakHandle. | 32 // SyncNotifierObserver to "observe" our Core via WeakHandle. |
| 33 public SyncNotifierObserver { | 33 public SyncNotifierObserver { |
| 34 public: | 34 public: |
| 35 // |invalidation_state_tracker| must be initialized. | 35 // |invalidation_state_tracker| must be initialized. |
| 36 NonBlockingInvalidationNotifier( | 36 NonBlockingInvalidationNotifier( |
| 37 const notifier::NotifierOptions& notifier_options, | 37 const notifier::NotifierOptions& notifier_options, |
| 38 const InvalidationVersionMap& initial_max_invalidation_versions, | 38 const InvalidationVersionMap& initial_max_invalidation_versions, |
| 39 const std::string& initial_invalidation_state, | 39 const std::string& initial_invalidation_state, |
| 40 const syncer::WeakHandle<InvalidationStateTracker>& | 40 const WeakHandle<InvalidationStateTracker>& |
| 41 invalidation_state_tracker, | 41 invalidation_state_tracker, |
| 42 const std::string& client_info); | 42 const std::string& client_info); |
| 43 | 43 |
| 44 virtual ~NonBlockingInvalidationNotifier(); | 44 virtual ~NonBlockingInvalidationNotifier(); |
| 45 | 45 |
| 46 // SyncNotifier implementation. | 46 // SyncNotifier implementation. |
| 47 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; | 47 virtual void AddObserver(SyncNotifierObserver* observer) OVERRIDE; |
| 48 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; | 48 virtual void RemoveObserver(SyncNotifierObserver* observer) OVERRIDE; |
| 49 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | 49 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; |
| 50 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; | 50 virtual void SetStateDeprecated(const std::string& state) OVERRIDE; |
| 51 virtual void UpdateCredentials( | 51 virtual void UpdateCredentials( |
| 52 const std::string& email, const std::string& token) OVERRIDE; | 52 const std::string& email, const std::string& token) OVERRIDE; |
| 53 virtual void UpdateEnabledTypes( | 53 virtual void UpdateEnabledTypes(ModelTypeSet enabled_types) OVERRIDE; |
| 54 syncer::ModelTypeSet enabled_types) OVERRIDE; | 54 virtual void SendNotification(ModelTypeSet changed_types) OVERRIDE; |
| 55 virtual void SendNotification( | |
| 56 syncer::ModelTypeSet changed_types) OVERRIDE; | |
| 57 | 55 |
| 58 // SyncNotifierObserver implementation. | 56 // SyncNotifierObserver implementation. |
| 59 virtual void OnNotificationsEnabled() OVERRIDE; | 57 virtual void OnNotificationsEnabled() OVERRIDE; |
| 60 virtual void OnNotificationsDisabled( | 58 virtual void OnNotificationsDisabled( |
| 61 NotificationsDisabledReason reason) OVERRIDE; | 59 NotificationsDisabledReason reason) OVERRIDE; |
| 62 virtual void OnIncomingNotification( | 60 virtual void OnIncomingNotification( |
| 63 const syncer::ModelTypePayloadMap& type_payloads, | 61 const ModelTypePayloadMap& type_payloads, |
| 64 IncomingNotificationSource source) OVERRIDE; | 62 IncomingNotificationSource source) OVERRIDE; |
| 65 | 63 |
| 66 private: | 64 private: |
| 67 class Core; | 65 class Core; |
| 68 | 66 |
| 69 base::WeakPtrFactory<NonBlockingInvalidationNotifier> weak_ptr_factory_; | 67 base::WeakPtrFactory<NonBlockingInvalidationNotifier> weak_ptr_factory_; |
| 70 | 68 |
| 71 // Our observers (which must live on the parent thread). | 69 // Our observers (which must live on the parent thread). |
| 72 ObserverList<SyncNotifierObserver> observers_; | 70 ObserverList<SyncNotifierObserver> observers_; |
| 73 | 71 |
| 74 // The real guts of NonBlockingInvalidationNotifier, which allows | 72 // The real guts of NonBlockingInvalidationNotifier, which allows |
| 75 // this class to live completely on the parent thread. | 73 // this class to live completely on the parent thread. |
| 76 scoped_refptr<Core> core_; | 74 scoped_refptr<Core> core_; |
| 77 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; | 75 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; |
| 78 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 79 | 77 |
| 80 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidationNotifier); | 78 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidationNotifier); |
| 81 }; | 79 }; |
| 82 | 80 |
| 83 } // namespace syncer | 81 } // namespace syncer |
| 84 | 82 |
| 85 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_ | 83 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_ |
| OLD | NEW |