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 25 matching lines...) Expand all Loading... |
36 const std::string& client_info); | 36 const std::string& client_info); |
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 UpdateCredentials(const std::string& email, const std::string& token); | 40 void UpdateCredentials(const std::string& email, const std::string& token); |
41 | 41 |
42 // InvalidationHandler implementation (all called on I/O thread by | 42 // InvalidationHandler implementation (all called on I/O thread by |
43 // InvalidationNotifier). | 43 // InvalidationNotifier). |
44 virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE; | 44 virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE; |
45 virtual void OnIncomingInvalidation( | 45 virtual void OnIncomingInvalidation( |
46 const ObjectIdInvalidationMap& invalidation_map, | 46 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
47 IncomingInvalidationSource source) OVERRIDE; | |
48 | 47 |
49 private: | 48 private: |
50 friend class | 49 friend class |
51 base::RefCountedThreadSafe<NonBlockingInvalidator::Core>; | 50 base::RefCountedThreadSafe<NonBlockingInvalidator::Core>; |
52 // Called on parent or I/O thread. | 51 // Called on parent or I/O thread. |
53 ~Core(); | 52 ~Core(); |
54 | 53 |
55 // The variables below should be used only on the I/O thread. | 54 // The variables below should be used only on the I/O thread. |
56 const WeakHandle<InvalidationHandler> delegate_observer_; | 55 const WeakHandle<InvalidationHandler> delegate_observer_; |
57 scoped_ptr<InvalidationNotifier> invalidation_notifier_; | 56 scoped_ptr<InvalidationNotifier> invalidation_notifier_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 114 } |
116 | 115 |
117 void NonBlockingInvalidator::Core::OnInvalidatorStateChange( | 116 void NonBlockingInvalidator::Core::OnInvalidatorStateChange( |
118 InvalidatorState reason) { | 117 InvalidatorState reason) { |
119 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 118 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
120 delegate_observer_.Call( | 119 delegate_observer_.Call( |
121 FROM_HERE, &InvalidationHandler::OnInvalidatorStateChange, reason); | 120 FROM_HERE, &InvalidationHandler::OnInvalidatorStateChange, reason); |
122 } | 121 } |
123 | 122 |
124 void NonBlockingInvalidator::Core::OnIncomingInvalidation( | 123 void NonBlockingInvalidator::Core::OnIncomingInvalidation( |
125 const ObjectIdInvalidationMap& invalidation_map, | 124 const ObjectIdInvalidationMap& invalidation_map) { |
126 IncomingInvalidationSource source) { | |
127 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 125 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
128 delegate_observer_.Call(FROM_HERE, | 126 delegate_observer_.Call(FROM_HERE, |
129 &InvalidationHandler::OnIncomingInvalidation, | 127 &InvalidationHandler::OnIncomingInvalidation, |
130 invalidation_map, | 128 invalidation_map); |
131 source); | |
132 } | 129 } |
133 | 130 |
134 NonBlockingInvalidator::NonBlockingInvalidator( | 131 NonBlockingInvalidator::NonBlockingInvalidator( |
135 const notifier::NotifierOptions& notifier_options, | 132 const notifier::NotifierOptions& notifier_options, |
136 const InvalidationStateMap& initial_max_invalidation_versions, | 133 const InvalidationStateMap& initial_max_invalidation_versions, |
137 const std::string& invalidation_bootstrap_data, | 134 const std::string& invalidation_bootstrap_data, |
138 const WeakHandle<InvalidationStateTracker>& | 135 const WeakHandle<InvalidationStateTracker>& |
139 invalidation_state_tracker, | 136 invalidation_state_tracker, |
140 const std::string& client_info) | 137 const std::string& client_info) |
141 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 138 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // InvalidationNotifier doesn't implement SendInvalidation(), so no | 222 // InvalidationNotifier doesn't implement SendInvalidation(), so no |
226 // need to forward on the call. | 223 // need to forward on the call. |
227 } | 224 } |
228 | 225 |
229 void NonBlockingInvalidator::OnInvalidatorStateChange(InvalidatorState state) { | 226 void NonBlockingInvalidator::OnInvalidatorStateChange(InvalidatorState state) { |
230 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 227 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
231 registrar_.UpdateInvalidatorState(state); | 228 registrar_.UpdateInvalidatorState(state); |
232 } | 229 } |
233 | 230 |
234 void NonBlockingInvalidator::OnIncomingInvalidation( | 231 void NonBlockingInvalidator::OnIncomingInvalidation( |
235 const ObjectIdInvalidationMap& invalidation_map, | 232 const ObjectIdInvalidationMap& invalidation_map) { |
236 IncomingInvalidationSource source) { | |
237 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 233 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
238 registrar_.DispatchInvalidationsToHandlers(invalidation_map, source); | 234 registrar_.DispatchInvalidationsToHandlers(invalidation_map); |
239 } | 235 } |
240 | 236 |
241 } // namespace syncer | 237 } // namespace syncer |
OLD | NEW |