| 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 10 matching lines...) Expand all Loading... |
| 21 #include "sync/notifier/invalidation_state_tracker.h" | 21 #include "sync/notifier/invalidation_state_tracker.h" |
| 22 #include "sync/notifier/invalidator.h" | 22 #include "sync/notifier/invalidator.h" |
| 23 #include "sync/notifier/invalidator_registrar.h" | 23 #include "sync/notifier/invalidator_registrar.h" |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class SingleThreadTaskRunner; | 26 class SingleThreadTaskRunner; |
| 27 } // namespace base | 27 } // namespace base |
| 28 | 28 |
| 29 namespace syncer { | 29 namespace syncer { |
| 30 | 30 |
| 31 // TODO(akalin): Generalize the interface so it can use any Invalidator. | |
| 32 // (http://crbug.com/140409). | |
| 33 class SYNC_EXPORT_PRIVATE NonBlockingInvalidator | 31 class SYNC_EXPORT_PRIVATE NonBlockingInvalidator |
| 34 : public Invalidator, | 32 : public Invalidator, |
| 35 // InvalidationHandler to "observe" our Core via WeakHandle. | 33 // InvalidationHandler to "observe" our Core via WeakHandle. |
| 36 public InvalidationHandler { | 34 public InvalidationHandler { |
| 37 public: | 35 public: |
| 38 // |invalidation_state_tracker| must be initialized. | 36 // |invalidation_state_tracker| must be initialized. |
| 39 NonBlockingInvalidator( | 37 NonBlockingInvalidator( |
| 40 const notifier::NotifierOptions& notifier_options, | 38 const notifier::NotifierOptions& notifier_options, |
| 41 const std::string& invalidator_client_id, | 39 const std::string& invalidator_client_id, |
| 42 const InvalidationStateMap& initial_invalidation_state_map, | 40 const UnackedInvalidationsMap& saved_invalidations, |
| 43 const std::string& invalidation_bootstrap_data, | 41 const std::string& invalidation_bootstrap_data, |
| 44 const WeakHandle<InvalidationStateTracker>& | 42 const WeakHandle<InvalidationStateTracker>& |
| 45 invalidation_state_tracker, | 43 invalidation_state_tracker, |
| 46 const std::string& client_info); | 44 const std::string& client_info); |
| 47 | 45 |
| 48 virtual ~NonBlockingInvalidator(); | 46 virtual ~NonBlockingInvalidator(); |
| 49 | 47 |
| 50 // Invalidator implementation. | 48 // Invalidator implementation. |
| 51 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; | 49 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; |
| 52 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 50 virtual void UpdateRegisteredIds(InvalidationHandler* handler, |
| 53 const ObjectIdSet& ids) OVERRIDE; | 51 const ObjectIdSet& ids) OVERRIDE; |
| 54 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; | 52 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; |
| 55 virtual void Acknowledge(const invalidation::ObjectId& id, | |
| 56 const AckHandle& ack_handle) OVERRIDE; | |
| 57 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; | 53 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; |
| 58 virtual void UpdateCredentials( | 54 virtual void UpdateCredentials( |
| 59 const std::string& email, const std::string& token) OVERRIDE; | 55 const std::string& email, const std::string& token) OVERRIDE; |
| 60 | 56 |
| 61 // InvalidationHandler implementation. | 57 // InvalidationHandler implementation. |
| 62 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | 58 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; |
| 63 virtual void OnIncomingInvalidation( | 59 virtual void OnIncomingInvalidation( |
| 64 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 60 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 65 | 61 |
| 66 private: | 62 private: |
| 67 class Core; | 63 class Core; |
| 68 | 64 |
| 69 InvalidatorRegistrar registrar_; | 65 InvalidatorRegistrar registrar_; |
| 70 | 66 |
| 71 // The real guts of NonBlockingInvalidator, which allows this class to live | 67 // The real guts of NonBlockingInvalidator, which allows this class to live |
| 72 // completely on the parent thread. | 68 // completely on the parent thread. |
| 73 scoped_refptr<Core> core_; | 69 scoped_refptr<Core> core_; |
| 74 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; | 70 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; |
| 75 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 71 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
| 76 | 72 |
| 77 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; | 73 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; |
| 78 | 74 |
| 79 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); | 75 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); |
| 80 }; | 76 }; |
| 81 | 77 |
| 82 } // namespace syncer | 78 } // namespace syncer |
| 83 | 79 |
| 84 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ | 80 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ |
| OLD | NEW |