| 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() 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() { return "Sync"; } |
| 152 |
| 150 NonBlockingInvalidator::NonBlockingInvalidator( | 153 NonBlockingInvalidator::NonBlockingInvalidator( |
| 151 NetworkChannelCreator network_channel_creator, | 154 NetworkChannelCreator network_channel_creator, |
| 152 const std::string& invalidator_client_id, | 155 const std::string& invalidator_client_id, |
| 153 const UnackedInvalidationsMap& saved_invalidations, | 156 const UnackedInvalidationsMap& saved_invalidations, |
| 154 const std::string& invalidation_bootstrap_data, | 157 const std::string& invalidation_bootstrap_data, |
| 155 const WeakHandle<InvalidationStateTracker>& | 158 const WeakHandle<InvalidationStateTracker>& |
| 156 invalidation_state_tracker, | 159 invalidation_state_tracker, |
| 157 const std::string& client_info, | 160 const std::string& client_info, |
| 158 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) | 161 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) |
| 159 : parent_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 162 : 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()); | 237 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 235 registrar_.UpdateInvalidatorState(state); | 238 registrar_.UpdateInvalidatorState(state); |
| 236 } | 239 } |
| 237 | 240 |
| 238 void NonBlockingInvalidator::OnIncomingInvalidation( | 241 void NonBlockingInvalidator::OnIncomingInvalidation( |
| 239 const ObjectIdInvalidationMap& invalidation_map) { | 242 const ObjectIdInvalidationMap& invalidation_map) { |
| 240 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 243 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 241 registrar_.DispatchInvalidationsToHandlers(invalidation_map); | 244 registrar_.DispatchInvalidationsToHandlers(invalidation_map); |
| 242 } | 245 } |
| 243 | 246 |
| 247 std::string NonBlockingInvalidator::GetOwnerName() { return "Sync"; } |
| 248 |
| 244 NetworkChannelCreator | 249 NetworkChannelCreator |
| 245 NonBlockingInvalidator::MakePushClientChannelCreator( | 250 NonBlockingInvalidator::MakePushClientChannelCreator( |
| 246 const notifier::NotifierOptions& notifier_options) { | 251 const notifier::NotifierOptions& notifier_options) { |
| 247 return base::Bind(SyncNetworkChannel::CreatePushClientChannel, | 252 return base::Bind(SyncNetworkChannel::CreatePushClientChannel, |
| 248 notifier_options); | 253 notifier_options); |
| 249 } | 254 } |
| 250 | 255 |
| 251 NetworkChannelCreator NonBlockingInvalidator::MakeGCMNetworkChannelCreator( | 256 NetworkChannelCreator NonBlockingInvalidator::MakeGCMNetworkChannelCreator( |
| 252 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 257 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 253 scoped_ptr<GCMNetworkChannelDelegate> delegate) { | 258 scoped_ptr<GCMNetworkChannelDelegate> delegate) { |
| 254 return base::Bind(&SyncNetworkChannel::CreateGCMNetworkChannel, | 259 return base::Bind(&SyncNetworkChannel::CreateGCMNetworkChannel, |
| 255 request_context_getter, | 260 request_context_getter, |
| 256 base::Passed(&delegate)); | 261 base::Passed(&delegate)); |
| 257 } | 262 } |
| 258 | 263 |
| 259 } // namespace syncer | 264 } // namespace syncer |
| OLD | NEW |