| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
| 127 DVLOG(2) << "Unregistering"; | 127 DVLOG(2) << "Unregistering"; |
| 128 invalidator_registrar_->UnregisterHandler(handler); | 128 invalidator_registrar_->UnregisterHandler(handler); |
| 129 if (invalidator_) { | 129 if (invalidator_) { |
| 130 invalidator_->UpdateRegisteredIds( | 130 invalidator_->UpdateRegisteredIds( |
| 131 this, | 131 this, |
| 132 invalidator_registrar_->GetAllRegisteredIds()); | 132 invalidator_registrar_->GetAllRegisteredIds()); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 void TiclInvalidationService::AcknowledgeInvalidation( | |
| 137 const invalidation::ObjectId& id, | |
| 138 const syncer::AckHandle& ack_handle) { | |
| 139 DCHECK(CalledOnValidThread()); | |
| 140 if (invalidator_) { | |
| 141 invalidator_->Acknowledge(id, ack_handle); | |
| 142 } | |
| 143 } | |
| 144 | |
| 145 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { | 136 syncer::InvalidatorState TiclInvalidationService::GetInvalidatorState() const { |
| 146 DCHECK(CalledOnValidThread()); | 137 DCHECK(CalledOnValidThread()); |
| 147 if (invalidator_) { | 138 if (invalidator_) { |
| 148 DVLOG(2) << "GetInvalidatorState returning " | 139 DVLOG(2) << "GetInvalidatorState returning " |
| 149 << invalidator_->GetInvalidatorState(); | 140 << invalidator_->GetInvalidatorState(); |
| 150 return invalidator_->GetInvalidatorState(); | 141 return invalidator_->GetInvalidatorState(); |
| 151 } else { | 142 } else { |
| 152 DVLOG(2) << "Invalidator currently stopped"; | 143 DVLOG(2) << "Invalidator currently stopped"; |
| 153 return syncer::TRANSIENT_INVALIDATION_ERROR; | 144 return syncer::TRANSIENT_INVALIDATION_ERROR; |
| 154 } | 145 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return; | 343 return; |
| 353 } | 344 } |
| 354 | 345 |
| 355 notifier::NotifierOptions options = | 346 notifier::NotifierOptions options = |
| 356 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); | 347 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); |
| 357 options.request_context_getter = profile_->GetRequestContext(); | 348 options.request_context_getter = profile_->GetRequestContext(); |
| 358 options.auth_mechanism = "X-OAUTH2"; | 349 options.auth_mechanism = "X-OAUTH2"; |
| 359 invalidator_.reset(new syncer::NonBlockingInvalidator( | 350 invalidator_.reset(new syncer::NonBlockingInvalidator( |
| 360 options, | 351 options, |
| 361 invalidator_storage_->GetInvalidatorClientId(), | 352 invalidator_storage_->GetInvalidatorClientId(), |
| 362 invalidator_storage_->GetAllInvalidationStates(), | 353 invalidator_storage_->GetSavedInvalidations(), |
| 363 invalidator_storage_->GetBootstrapData(), | 354 invalidator_storage_->GetBootstrapData(), |
| 364 syncer::WeakHandle<syncer::InvalidationStateTracker>( | 355 syncer::WeakHandle<syncer::InvalidationStateTracker>( |
| 365 invalidator_storage_->AsWeakPtr()), | 356 invalidator_storage_->AsWeakPtr()), |
| 366 content::GetUserAgent(GURL()))); | 357 content::GetUserAgent(GURL()))); |
| 367 | 358 |
| 368 UpdateInvalidatorCredentials(); | 359 UpdateInvalidatorCredentials(); |
| 369 | 360 |
| 370 invalidator_->RegisterHandler(this); | 361 invalidator_->RegisterHandler(this); |
| 371 invalidator_->UpdateRegisteredIds( | 362 invalidator_->UpdateRegisteredIds( |
| 372 this, | 363 this, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 397 } | 388 } |
| 398 | 389 |
| 399 // This service always expects to have a valid invalidator storage. | 390 // This service always expects to have a valid invalidator storage. |
| 400 // So we must not only clear the old one, but also start a new one. | 391 // So we must not only clear the old one, but also start a new one. |
| 401 invalidator_storage_->Clear(); | 392 invalidator_storage_->Clear(); |
| 402 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 393 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 403 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 394 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
| 404 } | 395 } |
| 405 | 396 |
| 406 } // namespace invalidation | 397 } // namespace invalidation |
| OLD | NEW |