Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_INVALIDATOR_H_ | 8 #ifndef SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ |
| 9 #define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ | 9 #define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 // TODO(akalin): Generalize the interface so it can use any Invalidator. | 31 // TODO(akalin): Generalize the interface so it can use any Invalidator. |
| 32 // (http://crbug.com/140409). | 32 // (http://crbug.com/140409). |
| 33 class SYNC_EXPORT_PRIVATE NonBlockingInvalidator | 33 class SYNC_EXPORT_PRIVATE NonBlockingInvalidator |
| 34 : public Invalidator, | 34 : public Invalidator, |
| 35 // InvalidationHandler to "observe" our Core via WeakHandle. | 35 // InvalidationHandler to "observe" our Core via WeakHandle. |
| 36 public InvalidationHandler { | 36 public InvalidationHandler { |
| 37 public: | 37 public: |
| 38 // |invalidation_state_tracker| must be initialized. | 38 // |invalidation_state_tracker| must be initialized. |
| 39 NonBlockingInvalidator( | 39 NonBlockingInvalidator( |
| 40 const notifier::NotifierOptions& notifier_options, | 40 const notifier::NotifierOptions& notifier_options, |
| 41 const std::string& invalidator_client_id, | |
| 41 const InvalidationStateMap& initial_invalidation_state_map, | 42 const InvalidationStateMap& initial_invalidation_state_map, |
| 42 const std::string& invalidation_bootstrap_data, | 43 const std::string& invalidation_bootstrap_data, |
| 43 const WeakHandle<InvalidationStateTracker>& | 44 const WeakHandle<InvalidationStateTracker>& |
| 44 invalidation_state_tracker, | 45 invalidation_state_tracker, |
| 45 const std::string& client_info); | 46 const std::string& client_info); |
| 46 | 47 |
| 47 virtual ~NonBlockingInvalidator(); | 48 virtual ~NonBlockingInvalidator(); |
| 48 | 49 |
| 49 // Invalidator implementation. | 50 // Invalidator implementation. |
| 50 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; | 51 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; |
| 51 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 52 virtual void UpdateRegisteredIds(InvalidationHandler* handler, |
| 52 const ObjectIdSet& ids) OVERRIDE; | 53 const ObjectIdSet& ids) OVERRIDE; |
| 53 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; | 54 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; |
| 54 virtual void Acknowledge(const invalidation::ObjectId& id, | 55 virtual void Acknowledge(const invalidation::ObjectId& id, |
| 55 const AckHandle& ack_handle) OVERRIDE; | 56 const AckHandle& ack_handle) OVERRIDE; |
| 56 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; | 57 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; |
| 57 virtual void SetUniqueId(const std::string& unique_id) OVERRIDE; | |
| 58 virtual void UpdateCredentials( | 58 virtual void UpdateCredentials( |
| 59 const std::string& email, const std::string& token) OVERRIDE; | 59 const std::string& email, const std::string& token) OVERRIDE; |
| 60 virtual void SendInvalidation( | 60 virtual void SendInvalidation( |
| 61 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 61 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 62 | 62 |
| 63 // InvalidationHandler implementation. | 63 // InvalidationHandler implementation. |
| 64 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | 64 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; |
| 65 virtual void OnIncomingInvalidation( | 65 virtual void OnIncomingInvalidation( |
| 66 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 66 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 class Core; | 69 class Core; |
| 70 | 70 |
| 71 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; | 71 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; |
| 72 | 72 |
| 73 InvalidatorRegistrar registrar_; | 73 InvalidatorRegistrar registrar_; |
| 74 | 74 |
| 75 // The real guts of NonBlockingInvalidator, which allows this class to live | 75 // The real guts of NonBlockingInvalidator, which allows this class to live |
| 76 // completely on the parent thread. | 76 // completely on the parent thread. |
| 77 scoped_refptr<Core> core_; | 77 scoped_refptr<Core> core_; |
| 78 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; | 78 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; |
| 79 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 79 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 80 | 80 |
| 81 // A copy of the owned invalidator's client ID. | |
| 82 const std::string invalidator_client_id_; | |
|
Nicolas Zea
2013/03/20 21:17:33
do we need to keep this around? it doesn't look li
rlarocque
2013/03/20 23:25:33
You're right. Fixed.
| |
| 83 | |
| 81 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); | 84 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); |
| 82 }; | 85 }; |
| 83 | 86 |
| 84 } // namespace syncer | 87 } // namespace syncer |
| 85 | 88 |
| 86 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ | 89 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ |
| OLD | NEW |