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_invalidator.h" | 5 #include "sync/notifier/non_blocking_invalidator.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 void Teardown(); | 37 void Teardown(); |
38 void UpdateRegisteredIds(const ObjectIdSet& ids); | 38 void UpdateRegisteredIds(const ObjectIdSet& ids); |
39 void SetUniqueId(const std::string& unique_id); | 39 void SetUniqueId(const std::string& unique_id); |
40 void SetStateDeprecated(const std::string& state); | 40 void SetStateDeprecated(const std::string& state); |
41 void UpdateCredentials(const std::string& email, const std::string& token); | 41 void UpdateCredentials(const std::string& email, const std::string& token); |
42 | 42 |
43 // InvalidationHandler implementation (all called on I/O thread by | 43 // InvalidationHandler implementation (all called on I/O thread by |
44 // InvalidationNotifier). | 44 // InvalidationNotifier). |
45 virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE; | 45 virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE; |
46 virtual void OnIncomingInvalidation( | 46 virtual void OnIncomingInvalidation( |
47 const ObjectIdStateMap& id_state_map, | 47 const ObjectIdInvalidationMap& invalidation_map, |
48 IncomingInvalidationSource source) OVERRIDE; | 48 IncomingInvalidationSource source) OVERRIDE; |
49 | 49 |
50 private: | 50 private: |
51 friend class | 51 friend class |
52 base::RefCountedThreadSafe<NonBlockingInvalidator::Core>; | 52 base::RefCountedThreadSafe<NonBlockingInvalidator::Core>; |
53 // Called on parent or I/O thread. | 53 // Called on parent or I/O thread. |
54 ~Core(); | 54 ~Core(); |
55 | 55 |
56 // The variables below should be used only on the I/O thread. | 56 // The variables below should be used only on the I/O thread. |
57 const WeakHandle<InvalidationHandler> delegate_observer_; | 57 const WeakHandle<InvalidationHandler> delegate_observer_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 void NonBlockingInvalidator::Core::OnInvalidatorStateChange( | 124 void NonBlockingInvalidator::Core::OnInvalidatorStateChange( |
125 InvalidatorState reason) { | 125 InvalidatorState reason) { |
126 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 126 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
127 delegate_observer_.Call( | 127 delegate_observer_.Call( |
128 FROM_HERE, &InvalidationHandler::OnInvalidatorStateChange, reason); | 128 FROM_HERE, &InvalidationHandler::OnInvalidatorStateChange, reason); |
129 } | 129 } |
130 | 130 |
131 void NonBlockingInvalidator::Core::OnIncomingInvalidation( | 131 void NonBlockingInvalidator::Core::OnIncomingInvalidation( |
132 const ObjectIdStateMap& id_state_map, IncomingInvalidationSource source) { | 132 const ObjectIdInvalidationMap& invalidation_map, |
| 133 IncomingInvalidationSource source) { |
133 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 134 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
134 delegate_observer_.Call(FROM_HERE, | 135 delegate_observer_.Call(FROM_HERE, |
135 &InvalidationHandler::OnIncomingInvalidation, | 136 &InvalidationHandler::OnIncomingInvalidation, |
136 id_state_map, | 137 invalidation_map, |
137 source); | 138 source); |
138 } | 139 } |
139 | 140 |
140 NonBlockingInvalidator::NonBlockingInvalidator( | 141 NonBlockingInvalidator::NonBlockingInvalidator( |
141 const notifier::NotifierOptions& notifier_options, | 142 const notifier::NotifierOptions& notifier_options, |
142 const InvalidationVersionMap& initial_max_invalidation_versions, | 143 const InvalidationVersionMap& initial_max_invalidation_versions, |
143 const std::string& invalidation_bootstrap_data, | 144 const std::string& invalidation_bootstrap_data, |
144 const WeakHandle<InvalidationStateTracker>& | 145 const WeakHandle<InvalidationStateTracker>& |
145 invalidation_state_tracker, | 146 invalidation_state_tracker, |
146 const std::string& client_info) | 147 const std::string& client_info) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 231 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
231 if (!network_task_runner_->PostTask( | 232 if (!network_task_runner_->PostTask( |
232 FROM_HERE, | 233 FROM_HERE, |
233 base::Bind(&NonBlockingInvalidator::Core::UpdateCredentials, | 234 base::Bind(&NonBlockingInvalidator::Core::UpdateCredentials, |
234 core_.get(), email, token))) { | 235 core_.get(), email, token))) { |
235 NOTREACHED(); | 236 NOTREACHED(); |
236 } | 237 } |
237 } | 238 } |
238 | 239 |
239 void NonBlockingInvalidator::SendInvalidation( | 240 void NonBlockingInvalidator::SendInvalidation( |
240 const ObjectIdStateMap& id_state_map) { | 241 const ObjectIdInvalidationMap& invalidation_map) { |
241 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 242 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
242 // InvalidationClient doesn't implement SendInvalidation(), so no | 243 // InvalidationNotifier doesn't implement SendInvalidation(), so no |
243 // need to forward on the call. | 244 // need to forward on the call. |
244 } | 245 } |
245 | 246 |
246 void NonBlockingInvalidator::OnInvalidatorStateChange(InvalidatorState state) { | 247 void NonBlockingInvalidator::OnInvalidatorStateChange(InvalidatorState state) { |
247 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 248 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
248 registrar_.UpdateInvalidatorState(state); | 249 registrar_.UpdateInvalidatorState(state); |
249 } | 250 } |
250 | 251 |
251 void NonBlockingInvalidator::OnIncomingInvalidation( | 252 void NonBlockingInvalidator::OnIncomingInvalidation( |
252 const ObjectIdStateMap& id_state_map, | 253 const ObjectIdInvalidationMap& invalidation_map, |
253 IncomingInvalidationSource source) { | 254 IncomingInvalidationSource source) { |
254 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 255 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
255 registrar_.DispatchInvalidationsToHandlers(id_state_map, source); | 256 registrar_.DispatchInvalidationsToHandlers(invalidation_map, source); |
256 } | 257 } |
257 | 258 |
258 } // namespace syncer | 259 } // namespace syncer |
OLD | NEW |