OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_ | 8 #ifndef COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_ |
9 #define COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_ | 9 #define COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_ |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 NonBlockingInvalidator( | 44 NonBlockingInvalidator( |
45 NetworkChannelCreator network_channel_creator, | 45 NetworkChannelCreator network_channel_creator, |
46 const std::string& invalidator_client_id, | 46 const std::string& invalidator_client_id, |
47 const UnackedInvalidationsMap& saved_invalidations, | 47 const UnackedInvalidationsMap& saved_invalidations, |
48 const std::string& invalidation_bootstrap_data, | 48 const std::string& invalidation_bootstrap_data, |
49 InvalidationStateTracker* invalidation_state_tracker, | 49 InvalidationStateTracker* invalidation_state_tracker, |
50 const std::string& client_info, | 50 const std::string& client_info, |
51 const scoped_refptr<net::URLRequestContextGetter>& | 51 const scoped_refptr<net::URLRequestContextGetter>& |
52 request_context_getter); | 52 request_context_getter); |
53 | 53 |
54 virtual ~NonBlockingInvalidator(); | 54 ~NonBlockingInvalidator() override; |
55 | 55 |
56 // Invalidator implementation. | 56 // Invalidator implementation. |
57 virtual void RegisterHandler(InvalidationHandler* handler) override; | 57 void RegisterHandler(InvalidationHandler* handler) override; |
58 virtual void UpdateRegisteredIds(InvalidationHandler* handler, | 58 void UpdateRegisteredIds(InvalidationHandler* handler, |
59 const ObjectIdSet& ids) override; | 59 const ObjectIdSet& ids) override; |
60 virtual void UnregisterHandler(InvalidationHandler* handler) override; | 60 void UnregisterHandler(InvalidationHandler* handler) override; |
61 virtual InvalidatorState GetInvalidatorState() const override; | 61 InvalidatorState GetInvalidatorState() const override; |
62 virtual void UpdateCredentials( | 62 void UpdateCredentials(const std::string& email, |
63 const std::string& email, const std::string& token) override; | 63 const std::string& token) override; |
64 virtual void RequestDetailedStatus( | 64 void RequestDetailedStatus(base::Callback<void(const base::DictionaryValue&)> |
65 base::Callback<void(const base::DictionaryValue&)> callback) const | 65 callback) const override; |
66 override; | |
67 | 66 |
68 // Static functions to construct callback that creates network channel for | 67 // Static functions to construct callback that creates network channel for |
69 // SyncSystemResources. The goal is to pass network channel to invalidator at | 68 // SyncSystemResources. The goal is to pass network channel to invalidator at |
70 // the same time not exposing channel specific parameters to invalidator and | 69 // the same time not exposing channel specific parameters to invalidator and |
71 // channel implementation to client of invalidator. | 70 // channel implementation to client of invalidator. |
72 static NetworkChannelCreator MakePushClientChannelCreator( | 71 static NetworkChannelCreator MakePushClientChannelCreator( |
73 const notifier::NotifierOptions& notifier_options); | 72 const notifier::NotifierOptions& notifier_options); |
74 static NetworkChannelCreator MakeGCMNetworkChannelCreator( | 73 static NetworkChannelCreator MakeGCMNetworkChannelCreator( |
75 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 74 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
76 scoped_ptr<GCMNetworkChannelDelegate> delegate); | 75 scoped_ptr<GCMNetworkChannelDelegate> delegate); |
77 | 76 |
78 // These methods are forwarded to the invalidation_state_tracker_. | 77 // These methods are forwarded to the invalidation_state_tracker_. |
79 virtual void ClearAndSetNewClientId(const std::string& data) override; | 78 void ClearAndSetNewClientId(const std::string& data) override; |
80 virtual std::string GetInvalidatorClientId() const override; | 79 std::string GetInvalidatorClientId() const override; |
81 virtual void SetBootstrapData(const std::string& data) override; | 80 void SetBootstrapData(const std::string& data) override; |
82 virtual std::string GetBootstrapData() const override; | 81 std::string GetBootstrapData() const override; |
83 virtual void SetSavedInvalidations( | 82 void SetSavedInvalidations(const UnackedInvalidationsMap& states) override; |
84 const UnackedInvalidationsMap& states) override; | 83 UnackedInvalidationsMap GetSavedInvalidations() const override; |
85 virtual UnackedInvalidationsMap GetSavedInvalidations() const override; | 84 void Clear() override; |
86 virtual void Clear() override; | |
87 | 85 |
88 private: | 86 private: |
89 void OnInvalidatorStateChange(InvalidatorState state); | 87 void OnInvalidatorStateChange(InvalidatorState state); |
90 void OnIncomingInvalidation(const ObjectIdInvalidationMap& invalidation_map); | 88 void OnIncomingInvalidation(const ObjectIdInvalidationMap& invalidation_map); |
91 std::string GetOwnerName() const; | 89 std::string GetOwnerName() const; |
92 | 90 |
93 friend class NonBlockingInvalidatorTestDelegate; | 91 friend class NonBlockingInvalidatorTestDelegate; |
94 | 92 |
95 struct InitializeOptions; | 93 struct InitializeOptions; |
96 class Core; | 94 class Core; |
97 | 95 |
98 InvalidatorRegistrar registrar_; | 96 InvalidatorRegistrar registrar_; |
99 InvalidationStateTracker* invalidation_state_tracker_; | 97 InvalidationStateTracker* invalidation_state_tracker_; |
100 | 98 |
101 // The real guts of NonBlockingInvalidator, which allows this class to live | 99 // The real guts of NonBlockingInvalidator, which allows this class to live |
102 // completely on the parent thread. | 100 // completely on the parent thread. |
103 scoped_refptr<Core> core_; | 101 scoped_refptr<Core> core_; |
104 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; | 102 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; |
105 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 103 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
106 | 104 |
107 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; | 105 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; |
108 | 106 |
109 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); | 107 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); |
110 }; | 108 }; |
111 | 109 |
112 } // namespace syncer | 110 } // namespace syncer |
113 | 111 |
114 #endif // COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_ | 112 #endif // COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_ |
OLD | NEW |