Chromium Code Reviews| 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 "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/invalidation/invalidation_service_util.h" | 9 #include "chrome/browser/invalidation/invalidation_service_util.h" |
| 10 #include "chrome/browser/managed_mode/managed_user_service.h" | 10 #include "chrome/browser/managed_mode/managed_user_service.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 break; | 251 break; |
| 252 } | 252 } |
| 253 default: { | 253 default: { |
| 254 // We have no way to notify the user of this. Do nothing. | 254 // We have no way to notify the user of this. Do nothing. |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 void TiclInvalidationService::OnInvalidatorStateChange( | 259 void TiclInvalidationService::OnInvalidatorStateChange( |
| 260 syncer::InvalidatorState state) { | 260 syncer::InvalidatorState state) { |
| 261 invalidator_registrar_->UpdateInvalidatorState(state); | 261 if (state == syncer::INVALIDATION_CREDENTIALS_REJECTED) { |
| 262 // This may be due to normal OAuth access token expiration. If so, we must | |
| 263 // fetch a new one using our refresh token. Resetting the invalidator's | |
| 264 // access token will not reset the invalidator's exponential backoff, so | |
| 265 // it's safe to try to update the token every time we receive this signal. | |
|
akalin
2013/07/31 22:37:46
Add comment saying that if the credentials continu
akalin
2013/07/31 22:42:45
per our discussion, transition to TRANSIENT_ERROR
rlarocque
2013/07/31 23:00:53
Done.
| |
| 266 RequestAccessToken(); | |
| 267 } else { | |
| 268 invalidator_registrar_->UpdateInvalidatorState(state); | |
| 269 } | |
| 262 } | 270 } |
| 263 | 271 |
| 264 void TiclInvalidationService::OnIncomingInvalidation( | 272 void TiclInvalidationService::OnIncomingInvalidation( |
| 265 const syncer::ObjectIdInvalidationMap& invalidation_map) { | 273 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
| 266 invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map); | 274 invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map); |
| 267 } | 275 } |
| 268 | 276 |
| 269 void TiclInvalidationService::Shutdown() { | 277 void TiclInvalidationService::Shutdown() { |
| 270 DCHECK(CalledOnValidThread()); | 278 DCHECK(CalledOnValidThread()); |
| 271 if (IsStarted()) { | 279 if (IsStarted()) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 } | 372 } |
| 365 | 373 |
| 366 // This service always expects to have a valid invalidator storage. | 374 // This service always expects to have a valid invalidator storage. |
| 367 // So we must not only clear the old one, but also start a new one. | 375 // So we must not only clear the old one, but also start a new one. |
| 368 invalidator_storage_->Clear(); | 376 invalidator_storage_->Clear(); |
| 369 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 377 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 370 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 378 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
| 371 } | 379 } |
| 372 | 380 |
| 373 } // namespace invalidation | 381 } // namespace invalidation |
| OLD | NEW |