Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1078)

Side by Side Diff: components/invalidation/ticl_invalidation_service.cc

Issue 1146533005: [Sync] InvalidationService shouldn't CHECK when registering ObjectId for more than one handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from Bartosz. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/invalidation/ticl_invalidation_service.h ('k') | sync/tools/sync_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/invalidation/ticl_invalidation_service.h" 5 #include "components/invalidation/ticl_invalidation_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "components/gcm_driver/gcm_driver.h" 9 #include "components/gcm_driver/gcm_driver.h"
10 #include "components/invalidation/gcm_invalidation_bridge.h" 10 #include "components/invalidation/gcm_invalidation_bridge.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void TiclInvalidationService::InitForTest( 101 void TiclInvalidationService::InitForTest(
102 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker, 102 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker,
103 syncer::Invalidator* invalidator) { 103 syncer::Invalidator* invalidator) {
104 // Here we perform the equivalent of Init() and StartInvalidator(), but with 104 // Here we perform the equivalent of Init() and StartInvalidator(), but with
105 // some minor changes to account for the fact that we're injecting the 105 // some minor changes to account for the fact that we're injecting the
106 // invalidator. 106 // invalidator.
107 invalidation_state_tracker_ = invalidation_state_tracker.Pass(); 107 invalidation_state_tracker_ = invalidation_state_tracker.Pass();
108 invalidator_.reset(invalidator); 108 invalidator_.reset(invalidator);
109 109
110 invalidator_->RegisterHandler(this); 110 invalidator_->RegisterHandler(this);
111 invalidator_->UpdateRegisteredIds( 111 CHECK(invalidator_->UpdateRegisteredIds(
112 this, 112 this, invalidator_registrar_->GetAllRegisteredIds()));
113 invalidator_registrar_->GetAllRegisteredIds());
114 } 113 }
115 114
116 void TiclInvalidationService::RegisterInvalidationHandler( 115 void TiclInvalidationService::RegisterInvalidationHandler(
117 syncer::InvalidationHandler* handler) { 116 syncer::InvalidationHandler* handler) {
118 DCHECK(CalledOnValidThread()); 117 DCHECK(CalledOnValidThread());
119 DVLOG(2) << "Registering an invalidation handler"; 118 DVLOG(2) << "Registering an invalidation handler";
120 invalidator_registrar_->RegisterHandler(handler); 119 invalidator_registrar_->RegisterHandler(handler);
121 logger_.OnRegistration(handler->GetOwnerName()); 120 logger_.OnRegistration(handler->GetOwnerName());
122 } 121 }
123 122
124 void TiclInvalidationService::UpdateRegisteredInvalidationIds( 123 bool TiclInvalidationService::UpdateRegisteredInvalidationIds(
125 syncer::InvalidationHandler* handler, 124 syncer::InvalidationHandler* handler,
126 const syncer::ObjectIdSet& ids) { 125 const syncer::ObjectIdSet& ids) {
127 DCHECK(CalledOnValidThread()); 126 DCHECK(CalledOnValidThread());
128 DVLOG(2) << "Registering ids: " << ids.size(); 127 DVLOG(2) << "Registering ids: " << ids.size();
129 invalidator_registrar_->UpdateRegisteredIds(handler, ids); 128 if (!invalidator_registrar_->UpdateRegisteredIds(handler, ids))
129 return false;
130 if (invalidator_) { 130 if (invalidator_) {
131 invalidator_->UpdateRegisteredIds( 131 CHECK(invalidator_->UpdateRegisteredIds(
132 this, 132 this, invalidator_registrar_->GetAllRegisteredIds()));
133 invalidator_registrar_->GetAllRegisteredIds());
134 } 133 }
135 logger_.OnUpdateIds(invalidator_registrar_->GetSanitizedHandlersIdsMap()); 134 logger_.OnUpdateIds(invalidator_registrar_->GetSanitizedHandlersIdsMap());
135 return true;
136 } 136 }
137 137
138 void TiclInvalidationService::UnregisterInvalidationHandler( 138 void TiclInvalidationService::UnregisterInvalidationHandler(
139 syncer::InvalidationHandler* handler) { 139 syncer::InvalidationHandler* handler) {
140 DCHECK(CalledOnValidThread()); 140 DCHECK(CalledOnValidThread());
141 DVLOG(2) << "Unregistering"; 141 DVLOG(2) << "Unregistering";
142 invalidator_registrar_->UnregisterHandler(handler); 142 invalidator_registrar_->UnregisterHandler(handler);
143 if (invalidator_) { 143 if (invalidator_) {
144 invalidator_->UpdateRegisteredIds( 144 CHECK(invalidator_->UpdateRegisteredIds(
145 this, 145 this, invalidator_registrar_->GetAllRegisteredIds()));
146 invalidator_registrar_->GetAllRegisteredIds());
147 } 146 }
148 logger_.OnUnregistration(handler->GetOwnerName()); 147 logger_.OnUnregistration(handler->GetOwnerName());
149 } 148 }
150 149
151 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { 150 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const {
152 DCHECK(CalledOnValidThread()); 151 DCHECK(CalledOnValidThread());
153 if (invalidator_) { 152 if (invalidator_) {
154 DVLOG(2) << "GetInvalidatorState returning " 153 DVLOG(2) << "GetInvalidatorState returning "
155 << invalidator_->GetInvalidatorState(); 154 << invalidator_->GetInvalidatorState();
156 return invalidator_->GetInvalidatorState(); 155 return invalidator_->GetInvalidatorState();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 invalidation_state_tracker_->GetInvalidatorClientId(), 394 invalidation_state_tracker_->GetInvalidatorClientId(),
396 invalidation_state_tracker_->GetSavedInvalidations(), 395 invalidation_state_tracker_->GetSavedInvalidations(),
397 invalidation_state_tracker_->GetBootstrapData(), 396 invalidation_state_tracker_->GetBootstrapData(),
398 invalidation_state_tracker_.get(), 397 invalidation_state_tracker_.get(),
399 user_agent_, 398 user_agent_,
400 request_context_)); 399 request_context_));
401 400
402 UpdateInvalidatorCredentials(); 401 UpdateInvalidatorCredentials();
403 402
404 invalidator_->RegisterHandler(this); 403 invalidator_->RegisterHandler(this);
405 invalidator_->UpdateRegisteredIds( 404 CHECK(invalidator_->UpdateRegisteredIds(
406 this, 405 this, invalidator_registrar_->GetAllRegisteredIds()));
407 invalidator_registrar_->GetAllRegisteredIds());
408 } 406 }
409 407
410 void TiclInvalidationService::UpdateInvalidationNetworkChannel() { 408 void TiclInvalidationService::UpdateInvalidationNetworkChannel() {
411 const InvalidationNetworkChannel network_channel_type = 409 const InvalidationNetworkChannel network_channel_type =
412 settings_provider_->UseGCMChannel() ? GCM_NETWORK_CHANNEL 410 settings_provider_->UseGCMChannel() ? GCM_NETWORK_CHANNEL
413 : PUSH_CLIENT_CHANNEL; 411 : PUSH_CLIENT_CHANNEL;
414 if (network_channel_type_ == network_channel_type) 412 if (network_channel_type_ == network_channel_type)
415 return; 413 return;
416 network_channel_type_ = network_channel_type; 414 network_channel_type_ = network_channel_type;
417 if (IsStarted()) { 415 if (IsStarted()) {
(...skipping 12 matching lines...) Expand all
430 } 428 }
431 429
432 void TiclInvalidationService::StopInvalidator() { 430 void TiclInvalidationService::StopInvalidator() {
433 DCHECK(invalidator_); 431 DCHECK(invalidator_);
434 gcm_invalidation_bridge_.reset(); 432 gcm_invalidation_bridge_.reset();
435 invalidator_->UnregisterHandler(this); 433 invalidator_->UnregisterHandler(this);
436 invalidator_.reset(); 434 invalidator_.reset();
437 } 435 }
438 436
439 } // namespace invalidation 437 } // namespace invalidation
OLDNEW
« no previous file with comments | « components/invalidation/ticl_invalidation_service.h ('k') | sync/tools/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698