| 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. |
| 266 // |
| 267 // We won't be receiving any invalidations while the refresh is in progress, |
| 268 // we set our state to TRANSIENT_INVALIDATION_ERROR. If the credentials |
| 269 // really are invalid, the refresh request should fail and |
| 270 // OnGetTokenFailure() will put us into a INVALIDATION_CREDENTIALS_REJECTED |
| 271 // state. |
| 272 invalidator_registrar_->UpdateInvalidatorState( |
| 273 syncer::TRANSIENT_INVALIDATION_ERROR); |
| 274 RequestAccessToken(); |
| 275 } else { |
| 276 invalidator_registrar_->UpdateInvalidatorState(state); |
| 277 } |
| 262 } | 278 } |
| 263 | 279 |
| 264 void TiclInvalidationService::OnIncomingInvalidation( | 280 void TiclInvalidationService::OnIncomingInvalidation( |
| 265 const syncer::ObjectIdInvalidationMap& invalidation_map) { | 281 const syncer::ObjectIdInvalidationMap& invalidation_map) { |
| 266 invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map); | 282 invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map); |
| 267 } | 283 } |
| 268 | 284 |
| 269 void TiclInvalidationService::Shutdown() { | 285 void TiclInvalidationService::Shutdown() { |
| 270 DCHECK(CalledOnValidThread()); | 286 DCHECK(CalledOnValidThread()); |
| 271 if (IsStarted()) { | 287 if (IsStarted()) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 380 } |
| 365 | 381 |
| 366 // This service always expects to have a valid invalidator storage. | 382 // 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. | 383 // So we must not only clear the old one, but also start a new one. |
| 368 invalidator_storage_->Clear(); | 384 invalidator_storage_->Clear(); |
| 369 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 385 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 370 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 386 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
| 371 } | 387 } |
| 372 | 388 |
| 373 } // namespace invalidation | 389 } // namespace invalidation |
| OLD | NEW |