| OLD | NEW |
| 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/impl/ticl_invalidation_service.h" | 5 #include "components/invalidation/impl/ticl_invalidation_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "components/gcm_driver/gcm_driver.h" | 9 #include "components/gcm_driver/gcm_driver.h" |
| 10 #include "components/invalidation/impl/gcm_invalidation_bridge.h" | 10 #include "components/invalidation/impl/gcm_invalidation_bridge.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 access_token_); | 198 access_token_); |
| 199 access_token_.clear(); | 199 access_token_.clear(); |
| 200 access_token_request_ = | 200 access_token_request_ = |
| 201 token_service->StartRequest(account_id, oauth2_scopes, this); | 201 token_service->StartRequest(account_id, oauth2_scopes, this); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void TiclInvalidationService::OnGetTokenSuccess( | 204 void TiclInvalidationService::OnGetTokenSuccess( |
| 205 const OAuth2TokenService::Request* request, | 205 const OAuth2TokenService::Request* request, |
| 206 const std::string& access_token, | 206 const std::string& access_token, |
| 207 const base::Time& expiration_time) { | 207 const base::Time& expiration_time) { |
| 208 DCHECK_EQ(access_token_request_, request); | 208 DCHECK_EQ(access_token_request_.get(), request); |
| 209 access_token_request_.reset(); | 209 access_token_request_.reset(); |
| 210 // Reset backoff time after successful response. | 210 // Reset backoff time after successful response. |
| 211 request_access_token_backoff_.Reset(); | 211 request_access_token_backoff_.Reset(); |
| 212 access_token_ = access_token; | 212 access_token_ = access_token; |
| 213 if (!IsStarted() && IsReadyToStart()) { | 213 if (!IsStarted() && IsReadyToStart()) { |
| 214 StartInvalidator(network_channel_type_); | 214 StartInvalidator(network_channel_type_); |
| 215 } else { | 215 } else { |
| 216 UpdateInvalidatorCredentials(); | 216 UpdateInvalidatorCredentials(); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 void TiclInvalidationService::OnGetTokenFailure( | 220 void TiclInvalidationService::OnGetTokenFailure( |
| 221 const OAuth2TokenService::Request* request, | 221 const OAuth2TokenService::Request* request, |
| 222 const GoogleServiceAuthError& error) { | 222 const GoogleServiceAuthError& error) { |
| 223 DCHECK_EQ(access_token_request_, request); | 223 DCHECK_EQ(access_token_request_.get(), request); |
| 224 DCHECK_NE(error.state(), GoogleServiceAuthError::NONE); | 224 DCHECK_NE(error.state(), GoogleServiceAuthError::NONE); |
| 225 access_token_request_.reset(); | 225 access_token_request_.reset(); |
| 226 switch (error.state()) { | 226 switch (error.state()) { |
| 227 case GoogleServiceAuthError::CONNECTION_FAILED: | 227 case GoogleServiceAuthError::CONNECTION_FAILED: |
| 228 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: { | 228 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: { |
| 229 // Transient error. Retry after some time. | 229 // Transient error. Retry after some time. |
| 230 request_access_token_backoff_.InformOfRequest(false); | 230 request_access_token_backoff_.InformOfRequest(false); |
| 231 request_access_token_retry_timer_.Start( | 231 request_access_token_retry_timer_.Start( |
| 232 FROM_HERE, | 232 FROM_HERE, |
| 233 request_access_token_backoff_.GetTimeUntilRelease(), | 233 request_access_token_backoff_.GetTimeUntilRelease(), |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 431 } |
| 432 | 432 |
| 433 void TiclInvalidationService::StopInvalidator() { | 433 void TiclInvalidationService::StopInvalidator() { |
| 434 DCHECK(invalidator_); | 434 DCHECK(invalidator_); |
| 435 gcm_invalidation_bridge_.reset(); | 435 gcm_invalidation_bridge_.reset(); |
| 436 invalidator_->UnregisterHandler(this); | 436 invalidator_->UnregisterHandler(this); |
| 437 invalidator_.reset(); | 437 invalidator_.reset(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace invalidation | 440 } // namespace invalidation |
| OLD | NEW |