| 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 12 matching lines...) Expand all Loading... |
| 23 public InvalidationHandler { | 23 public InvalidationHandler { |
| 24 public: | 24 public: |
| 25 // Called on parent thread. |delegate_observer| should be | 25 // Called on parent thread. |delegate_observer| should be |
| 26 // initialized. | 26 // initialized. |
| 27 explicit Core( | 27 explicit Core( |
| 28 const WeakHandle<InvalidationHandler>& delegate_observer); | 28 const WeakHandle<InvalidationHandler>& delegate_observer); |
| 29 | 29 |
| 30 // Helpers called on I/O thread. | 30 // Helpers called on I/O thread. |
| 31 void Initialize( | 31 void Initialize( |
| 32 const notifier::NotifierOptions& notifier_options, | 32 const notifier::NotifierOptions& notifier_options, |
| 33 const InvalidationVersionMap& initial_max_invalidation_versions, | 33 const InvalidationStateMap& initial_invalidation_state_map, |
| 34 const std::string& invalidation_bootstrap_data, | 34 const std::string& invalidation_bootstrap_data, |
| 35 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, | 35 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, |
| 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 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 65 const WeakHandle<InvalidationHandler>& delegate_observer) | 65 const WeakHandle<InvalidationHandler>& delegate_observer) |
| 66 : delegate_observer_(delegate_observer) { | 66 : delegate_observer_(delegate_observer) { |
| 67 DCHECK(delegate_observer_.IsInitialized()); | 67 DCHECK(delegate_observer_.IsInitialized()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 NonBlockingInvalidator::Core::~Core() { | 70 NonBlockingInvalidator::Core::~Core() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 void NonBlockingInvalidator::Core::Initialize( | 73 void NonBlockingInvalidator::Core::Initialize( |
| 74 const notifier::NotifierOptions& notifier_options, | 74 const notifier::NotifierOptions& notifier_options, |
| 75 const InvalidationVersionMap& initial_max_invalidation_versions, | 75 const InvalidationStateMap& initial_invalidation_state_map, |
| 76 const std::string& invalidation_bootstrap_data, | 76 const std::string& invalidation_bootstrap_data, |
| 77 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, | 77 const WeakHandle<InvalidationStateTracker>& invalidation_state_tracker, |
| 78 const std::string& client_info) { | 78 const std::string& client_info) { |
| 79 DCHECK(notifier_options.request_context_getter); | 79 DCHECK(notifier_options.request_context_getter); |
| 80 DCHECK_EQ(notifier::NOTIFICATION_SERVER, | 80 DCHECK_EQ(notifier::NOTIFICATION_SERVER, |
| 81 notifier_options.notification_method); | 81 notifier_options.notification_method); |
| 82 network_task_runner_ = notifier_options.request_context_getter-> | 82 network_task_runner_ = notifier_options.request_context_getter-> |
| 83 GetNetworkTaskRunner(); | 83 GetNetworkTaskRunner(); |
| 84 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 84 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 85 invalidation_notifier_.reset( | 85 invalidation_notifier_.reset( |
| 86 new InvalidationNotifier( | 86 new InvalidationNotifier( |
| 87 notifier::PushClient::CreateDefaultOnIOThread(notifier_options), | 87 notifier::PushClient::CreateDefaultOnIOThread(notifier_options), |
| 88 initial_max_invalidation_versions, | 88 initial_invalidation_state_map, |
| 89 invalidation_bootstrap_data, | 89 invalidation_bootstrap_data, |
| 90 invalidation_state_tracker, | 90 invalidation_state_tracker, |
| 91 client_info)); | 91 client_info)); |
| 92 invalidation_notifier_->RegisterHandler(this); | 92 invalidation_notifier_->RegisterHandler(this); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void NonBlockingInvalidator::Core::Teardown() { | 95 void NonBlockingInvalidator::Core::Teardown() { |
| 96 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 96 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 97 invalidation_notifier_->UnregisterHandler(this); | 97 invalidation_notifier_->UnregisterHandler(this); |
| 98 invalidation_notifier_.reset(); | 98 invalidation_notifier_.reset(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 IncomingInvalidationSource source) { | 133 IncomingInvalidationSource source) { |
| 134 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 134 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 135 delegate_observer_.Call(FROM_HERE, | 135 delegate_observer_.Call(FROM_HERE, |
| 136 &InvalidationHandler::OnIncomingInvalidation, | 136 &InvalidationHandler::OnIncomingInvalidation, |
| 137 invalidation_map, | 137 invalidation_map, |
| 138 source); | 138 source); |
| 139 } | 139 } |
| 140 | 140 |
| 141 NonBlockingInvalidator::NonBlockingInvalidator( | 141 NonBlockingInvalidator::NonBlockingInvalidator( |
| 142 const notifier::NotifierOptions& notifier_options, | 142 const notifier::NotifierOptions& notifier_options, |
| 143 const InvalidationVersionMap& initial_max_invalidation_versions, | 143 const InvalidationStateMap& initial_max_invalidation_versions, |
| 144 const std::string& invalidation_bootstrap_data, | 144 const std::string& invalidation_bootstrap_data, |
| 145 const WeakHandle<InvalidationStateTracker>& | 145 const WeakHandle<InvalidationStateTracker>& |
| 146 invalidation_state_tracker, | 146 invalidation_state_tracker, |
| 147 const std::string& client_info) | 147 const std::string& client_info) |
| 148 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 148 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 149 core_( | 149 core_( |
| 150 new Core(MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()))), | 150 new Core(MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()))), |
| 151 parent_task_runner_( | 151 parent_task_runner_( |
| 152 base::ThreadTaskRunnerHandle::Get()), | 152 base::ThreadTaskRunnerHandle::Get()), |
| 153 network_task_runner_(notifier_options.request_context_getter-> | 153 network_task_runner_(notifier_options.request_context_getter-> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 void NonBlockingInvalidator::OnIncomingInvalidation( | 252 void NonBlockingInvalidator::OnIncomingInvalidation( |
| 253 const ObjectIdInvalidationMap& invalidation_map, | 253 const ObjectIdInvalidationMap& invalidation_map, |
| 254 IncomingInvalidationSource source) { | 254 IncomingInvalidationSource source) { |
| 255 DCHECK(parent_task_runner_->BelongsToCurrentThread()); | 255 DCHECK(parent_task_runner_->BelongsToCurrentThread()); |
| 256 registrar_.DispatchInvalidationsToHandlers(invalidation_map, source); | 256 registrar_.DispatchInvalidationsToHandlers(invalidation_map, source); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace syncer | 259 } // namespace syncer |
| OLD | NEW |