| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const NonBlockingInvalidator::InitializeOptions& initialize_options); | 64 const NonBlockingInvalidator::InitializeOptions& initialize_options); |
| 65 void Teardown(); | 65 void Teardown(); |
| 66 void UpdateRegisteredIds(const ObjectIdSet& ids); | 66 void UpdateRegisteredIds(const ObjectIdSet& ids); |
| 67 void UpdateCredentials(const std::string& email, const std::string& token); | 67 void UpdateCredentials(const std::string& email, const std::string& token); |
| 68 | 68 |
| 69 // InvalidationHandler implementation (all called on I/O thread by | 69 // InvalidationHandler implementation (all called on I/O thread by |
| 70 // InvalidationNotifier). | 70 // InvalidationNotifier). |
| 71 virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE; | 71 virtual void OnInvalidatorStateChange(InvalidatorState reason) OVERRIDE; |
| 72 virtual void OnIncomingInvalidation( | 72 virtual void OnIncomingInvalidation( |
| 73 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 73 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 74 virtual std::string GetOwnerName() const OVERRIDE; |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 friend class | 77 friend class |
| 77 base::RefCountedThreadSafe<NonBlockingInvalidator::Core>; | 78 base::RefCountedThreadSafe<NonBlockingInvalidator::Core>; |
| 78 // Called on parent or I/O thread. | 79 // Called on parent or I/O thread. |
| 79 virtual ~Core(); | 80 virtual ~Core(); |
| 80 | 81 |
| 81 // The variables below should be used only on the I/O thread. | 82 // The variables below should be used only on the I/O thread. |
| 82 const WeakHandle<InvalidationHandler> delegate_observer_; | 83 const WeakHandle<InvalidationHandler> delegate_observer_; |
| 83 scoped_ptr<InvalidationNotifier> invalidation_notifier_; | 84 scoped_ptr<InvalidationNotifier> invalidation_notifier_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 141 } |
| 141 | 142 |
| 142 void NonBlockingInvalidator::Core::OnIncomingInvalidation( | 143 void NonBlockingInvalidator::Core::OnIncomingInvalidation( |
| 143 const ObjectIdInvalidationMap& invalidation_map) { | 144 const ObjectIdInvalidationMap& invalidation_map) { |
| 144 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 145 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 145 delegate_observer_.Call(FROM_HERE, | 146 delegate_observer_.Call(FROM_HERE, |
| 146 &InvalidationHandler::OnIncomingInvalidation, | 147 &InvalidationHandler::OnIncomingInvalidation, |
| 147 invalidation_map); | 148 invalidation_map); |
| 148 } | 149 } |
| 149 | 150 |
| 151 std::string NonBlockingInvalidator::Core::GetOwnerName() const { |
| 152 return "Sync"; |
| 153 } |
| 154 |
| 150 NonBlockingInvalidator::NonBlockingInvalidator( | 155 NonBlockingInvalidator::NonBlockingInvalidator( |
| 151 NetworkChannelCreator network_channel_creator, | 156 NetworkChannelCreator network_channel_creator, |
| 152 const std::string& invalidator_client_id, | 157 const std::string& invalidator_client_id, |
| 153 const UnackedInvalidationsMap& saved_invalidations, | 158 const UnackedInvalidationsMap& saved_invalidations, |
| 154 const std::string& invalidation_bootstrap_data, | 159 const std::string& invalidation_bootstrap_data, |
| 155 const WeakHandle<InvalidationStateTracker>& | 160 const WeakHandle<InvalidationStateTracker>& |
| 156 invalidation_state_tracker, | 161 invalidation_state_tracker, |
| 157 const std::string& client_info, | 162 const std::string& client_info, |
| 158 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) | 163 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) |
| 159 : parent_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 164 : parent_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 239 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 235 registrar_.UpdateInvalidatorState(state); | 240 registrar_.UpdateInvalidatorState(state); |
| 236 } | 241 } |
| 237 | 242 |
| 238 void NonBlockingInvalidator::OnIncomingInvalidation( | 243 void NonBlockingInvalidator::OnIncomingInvalidation( |
| 239 const ObjectIdInvalidationMap& invalidation_map) { | 244 const ObjectIdInvalidationMap& invalidation_map) { |
| 240 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 245 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 241 registrar_.DispatchInvalidationsToHandlers(invalidation_map); | 246 registrar_.DispatchInvalidationsToHandlers(invalidation_map); |
| 242 } | 247 } |
| 243 | 248 |
| 249 std::string NonBlockingInvalidator::GetOwnerName() const { return "Sync"; } |
| 250 |
| 244 NetworkChannelCreator | 251 NetworkChannelCreator |
| 245 NonBlockingInvalidator::MakePushClientChannelCreator( | 252 NonBlockingInvalidator::MakePushClientChannelCreator( |
| 246 const notifier::NotifierOptions& notifier_options) { | 253 const notifier::NotifierOptions& notifier_options) { |
| 247 return base::Bind(SyncNetworkChannel::CreatePushClientChannel, | 254 return base::Bind(SyncNetworkChannel::CreatePushClientChannel, |
| 248 notifier_options); | 255 notifier_options); |
| 249 } | 256 } |
| 250 | 257 |
| 251 NetworkChannelCreator NonBlockingInvalidator::MakeGCMNetworkChannelCreator( | 258 NetworkChannelCreator NonBlockingInvalidator::MakeGCMNetworkChannelCreator( |
| 252 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 259 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 253 scoped_ptr<GCMNetworkChannelDelegate> delegate) { | 260 scoped_ptr<GCMNetworkChannelDelegate> delegate) { |
| 254 return base::Bind(&SyncNetworkChannel::CreateGCMNetworkChannel, | 261 return base::Bind(&SyncNetworkChannel::CreateGCMNetworkChannel, |
| 255 request_context_getter, | 262 request_context_getter, |
| 256 base::Passed(&delegate)); | 263 base::Passed(&delegate)); |
| 257 } | 264 } |
| 258 | 265 |
| 259 } // namespace syncer | 266 } // namespace syncer |
| OLD | NEW |