Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/login/oauth1_token_fetcher.h" | 5 #include "chrome/browser/chromeos/login/oauth1_token_fetcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 #include "chrome/browser/chromeos/cros/network_library.h" | 9 #include "chrome/browser/chromeos/cros/network_library.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
|
Joao da Silva
2013/01/11 16:45:07
Not needed
zel
2013/01/11 19:51:16
Done.
| |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "google_apis/gaia/google_service_auth_error.h" | 12 #include "google_apis/gaia/google_service_auth_error.h" |
| 13 | 13 |
| 14 using content::BrowserThread; | 14 using content::BrowserThread; |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // OAuth token request max retry count. | 18 // OAuth token request max retry count. |
| 19 const int kMaxOAuth1TokenRequestAttemptCount = 5; | 19 const int kMaxOAuth1TokenRequestAttemptCount = 5; |
| 20 // OAuth token request retry delay in milliseconds. | 20 // OAuth token request retry delay in milliseconds. |
| 21 const int kOAuth1TokenRequestRestartDelay = 3000; | 21 const int kOAuth1TokenRequestRestartDelay = 3000; |
| 22 | 22 |
| 23 // The service scope of the OAuth v2 token that ChromeOS login will be | 23 // The service scope of the OAuth v2 token that ChromeOS login will be |
| 24 // requesting. | 24 // requesting. |
| 25 const char kServiceScopeChromeOS[] = | 25 const char kServiceScopeChromeOS[] = |
| 26 "https://www.googleapis.com/auth/chromesync"; | 26 "https://www.googleapis.com/auth/chromesync"; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 namespace chromeos { | 30 namespace chromeos { |
| 31 | 31 |
| 32 OAuth1TokenFetcher::OAuth1TokenFetcher(OAuth1TokenFetcher::Delegate* delegate, | 32 OAuth1TokenFetcher::OAuth1TokenFetcher( |
| 33 Profile* auth_profile) | 33 OAuth1TokenFetcher::Delegate* delegate, |
| 34 net::URLRequestContextGetter* auth_context_getter) | |
| 34 : delegate_(delegate), | 35 : delegate_(delegate), |
| 35 auth_profile_(auth_profile), | 36 oauth_fetcher_(this, auth_context_getter, kServiceScopeChromeOS), |
| 36 oauth_fetcher_(this, | |
| 37 auth_profile_->GetRequestContext(), | |
| 38 kServiceScopeChromeOS), | |
| 39 retry_count_(0) { | 37 retry_count_(0) { |
| 40 DCHECK(delegate); | 38 DCHECK(delegate); |
| 41 } | 39 } |
| 42 | 40 |
| 43 OAuth1TokenFetcher::~OAuth1TokenFetcher() { | 41 OAuth1TokenFetcher::~OAuth1TokenFetcher() { |
| 44 } | 42 } |
| 45 | 43 |
| 46 void OAuth1TokenFetcher::Start() { | 44 void OAuth1TokenFetcher::Start() { |
| 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 48 if (CrosLibrary::Get()->libcros_loaded()) { | 46 if (CrosLibrary::Get()->libcros_loaded()) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 100 |
| 103 void OAuth1TokenFetcher::OnOAuthGetAccessTokenFailure( | 101 void OAuth1TokenFetcher::OnOAuthGetAccessTokenFailure( |
| 104 const GoogleServiceAuthError& error) { | 102 const GoogleServiceAuthError& error) { |
| 105 LOG(WARNING) << "Failed fetching OAuth1 access token, error: " | 103 LOG(WARNING) << "Failed fetching OAuth1 access token, error: " |
| 106 << error.state(); | 104 << error.state(); |
| 107 if (!RetryOnError(error)) | 105 if (!RetryOnError(error)) |
| 108 delegate_->OnOAuth1AccessTokenFetchFailed(); | 106 delegate_->OnOAuth1AccessTokenFetchFailed(); |
| 109 } | 107 } |
| 110 | 108 |
| 111 } // namespace chromeos | 109 } // namespace chromeos |
| OLD | NEW |