| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/invalidation/ticl_invalidation_service.h" | 5 #include "chrome/browser/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 "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/invalidation/invalidation_service_util.h" | 10 #include "chrome/browser/invalidation/invalidation_service_util.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 DCHECK(CalledOnValidThread()); | 133 DCHECK(CalledOnValidThread()); |
| 134 DVLOG(2) << "Unregistering"; | 134 DVLOG(2) << "Unregistering"; |
| 135 invalidator_registrar_->UnregisterHandler(handler); | 135 invalidator_registrar_->UnregisterHandler(handler); |
| 136 if (invalidator_) { | 136 if (invalidator_) { |
| 137 invalidator_->UpdateRegisteredIds( | 137 invalidator_->UpdateRegisteredIds( |
| 138 this, | 138 this, |
| 139 invalidator_registrar_->GetAllRegisteredIds()); | 139 invalidator_registrar_->GetAllRegisteredIds()); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void TiclInvalidationService::AcknowledgeInvalidation( | |
| 144 const invalidation::ObjectId& id, | |
| 145 const syncer::AckHandle& ack_handle) { | |
| 146 DCHECK(CalledOnValidThread()); | |
| 147 if (invalidator_) { | |
| 148 invalidator_->Acknowledge(id, ack_handle); | |
| 149 } | |
| 150 } | |
| 151 | |
| 152 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { | 143 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { |
| 153 DCHECK(CalledOnValidThread()); | 144 DCHECK(CalledOnValidThread()); |
| 154 if (invalidator_) { | 145 if (invalidator_) { |
| 155 DVLOG(2) << "GetInvalidatorState returning " | 146 DVLOG(2) << "GetInvalidatorState returning " |
| 156 << invalidator_->GetInvalidatorState(); | 147 << invalidator_->GetInvalidatorState(); |
| 157 return invalidator_->GetInvalidatorState(); | 148 return invalidator_->GetInvalidatorState(); |
| 158 } else { | 149 } else { |
| 159 DVLOG(2) << "Invalidator currently stopped"; | 150 DVLOG(2) << "Invalidator currently stopped"; |
| 160 return syncer::TRANSIENT_INVALIDATION_ERROR; | 151 return syncer::TRANSIENT_INVALIDATION_ERROR; |
| 161 } | 152 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // state. | 281 // state. |
| 291 invalidator_registrar_->UpdateInvalidatorState( | 282 invalidator_registrar_->UpdateInvalidatorState( |
| 292 syncer::TRANSIENT_INVALIDATION_ERROR); | 283 syncer::TRANSIENT_INVALIDATION_ERROR); |
| 293 RequestAccessToken(); | 284 RequestAccessToken(); |
| 294 } else { | 285 } else { |
| 295 invalidator_registrar_->UpdateInvalidatorState(state); | 286 invalidator_registrar_->UpdateInvalidatorState(state); |
| 296 } | 287 } |
| 297 } | 288 } |
| 298 | 289 |
| 299 void TiclInvalidationService::OnIncomingInvalidation( | 290 void TiclInvalidationService::OnIncomingInvalidation( |
| 300 const syncer::ObjectIdInvalidationMap& invalidation_map) { | 291 const syncer::ObjectIdInvalidationMap& invalidations) { |
| 301 invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map); | 292 invalidator_registrar_->DispatchInvalidationsToHandlers(invalidations); |
| 302 } | 293 } |
| 303 | 294 |
| 304 void TiclInvalidationService::Shutdown() { | 295 void TiclInvalidationService::Shutdown() { |
| 305 DCHECK(CalledOnValidThread()); | 296 DCHECK(CalledOnValidThread()); |
| 306 if (IsStarted()) { | 297 if (IsStarted()) { |
| 307 StopInvalidator(); | 298 StopInvalidator(); |
| 308 } | 299 } |
| 309 invalidator_storage_.reset(); | 300 invalidator_storage_.reset(); |
| 310 invalidator_registrar_.reset(); | 301 invalidator_registrar_.reset(); |
| 311 } | 302 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 return; | 345 return; |
| 355 } | 346 } |
| 356 | 347 |
| 357 notifier::NotifierOptions options = | 348 notifier::NotifierOptions options = |
| 358 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); | 349 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); |
| 359 options.request_context_getter = profile_->GetRequestContext(); | 350 options.request_context_getter = profile_->GetRequestContext(); |
| 360 options.auth_mechanism = "X-OAUTH2"; | 351 options.auth_mechanism = "X-OAUTH2"; |
| 361 invalidator_.reset(new syncer::NonBlockingInvalidator( | 352 invalidator_.reset(new syncer::NonBlockingInvalidator( |
| 362 options, | 353 options, |
| 363 invalidator_storage_->GetInvalidatorClientId(), | 354 invalidator_storage_->GetInvalidatorClientId(), |
| 364 invalidator_storage_->GetAllInvalidationStates(), | 355 invalidator_storage_->GetSavedInvalidations(), |
| 365 invalidator_storage_->GetBootstrapData(), | 356 invalidator_storage_->GetBootstrapData(), |
| 366 syncer::WeakHandle<syncer::InvalidationStateTracker>( | 357 syncer::WeakHandle<syncer::InvalidationStateTracker>( |
| 367 invalidator_storage_->AsWeakPtr()), | 358 invalidator_storage_->AsWeakPtr()), |
| 368 content::GetUserAgent(GURL()))); | 359 content::GetUserAgent(GURL()))); |
| 369 | 360 |
| 370 UpdateInvalidatorCredentials(); | 361 UpdateInvalidatorCredentials(); |
| 371 | 362 |
| 372 invalidator_->RegisterHandler(this); | 363 invalidator_->RegisterHandler(this); |
| 373 invalidator_->UpdateRegisteredIds( | 364 invalidator_->UpdateRegisteredIds( |
| 374 this, | 365 this, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 399 } | 390 } |
| 400 | 391 |
| 401 // This service always expects to have a valid invalidator storage. | 392 // This service always expects to have a valid invalidator storage. |
| 402 // So we must not only clear the old one, but also start a new one. | 393 // So we must not only clear the old one, but also start a new one. |
| 403 invalidator_storage_->Clear(); | 394 invalidator_storage_->Clear(); |
| 404 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 395 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 405 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 396 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
| 406 } | 397 } |
| 407 | 398 |
| 408 } // namespace invalidation | 399 } // namespace invalidation |
| OLD | NEW |