summaryrefslogtreecommitdiffstats
path: root/google_apis/gaia
diff options
context:
space:
mode:
authorbzanotti <bzanotti@chromium.org>2015-06-04 14:10:04 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-04 21:10:33 +0000
commit76396518e3e6007588c3d1a64ce24fd3b84dd7ab (patch)
treee2a05a43d2680fcea79a6c33fa2d1d7f19957d0f /google_apis/gaia
parentb7056f63218b3ceb0301278334b8b8c203c6a3f0 (diff)
downloadchromium_src-76396518e3e6007588c3d1a64ce24fd3b84dd7ab.zip
chromium_src-76396518e3e6007588c3d1a64ce24fd3b84dd7ab.tar.gz
chromium_src-76396518e3e6007588c3d1a64ce24fd3b84dd7ab.tar.bz2
Incorporate GaiaAuthFetcher creation into SigninClient.
Added a CreateGaiaAuthFetcher method to the SigninClient to allow the usage of a platform-specific GaiaAuthFetcher. BUG= Review URL: https://codereview.chromium.org/1162303002 Cr-Commit-Position: refs/heads/master@{#332908}
Diffstat (limited to 'google_apis/gaia')
-rw-r--r--google_apis/gaia/ubertoken_fetcher.cc28
-rw-r--r--google_apis/gaia/ubertoken_fetcher.h11
2 files changed, 36 insertions, 3 deletions
diff --git a/google_apis/gaia/ubertoken_fetcher.cc b/google_apis/gaia/ubertoken_fetcher.cc
index 24cb53d..d72c60c 100644
--- a/google_apis/gaia/ubertoken_fetcher.cc
+++ b/google_apis/gaia/ubertoken_fetcher.cc
@@ -15,6 +15,15 @@
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_token_service.h"
+namespace {
+GaiaAuthFetcher* CreateGaiaAuthFetcher(
+ GaiaAuthConsumer* consumer,
+ const std::string& source,
+ net::URLRequestContextGetter* request_context) {
+ return new GaiaAuthFetcher(consumer, source, request_context);
+}
+}
+
const int UbertokenFetcher::kMaxRetries = 3;
UbertokenFetcher::UbertokenFetcher(
@@ -22,11 +31,25 @@ UbertokenFetcher::UbertokenFetcher(
UbertokenConsumer* consumer,
const std::string& source,
net::URLRequestContextGetter* request_context)
+ : UbertokenFetcher(token_service,
+ consumer,
+ source,
+ request_context,
+ base::Bind(CreateGaiaAuthFetcher)) {
+}
+
+UbertokenFetcher::UbertokenFetcher(
+ OAuth2TokenService* token_service,
+ UbertokenConsumer* consumer,
+ const std::string& source,
+ net::URLRequestContextGetter* request_context,
+ GaiaAuthFetcherFactory factory)
: OAuth2TokenService::Consumer("uber_token_fetcher"),
token_service_(token_service),
consumer_(consumer),
source_(source),
request_context_(request_context),
+ gaia_auth_fetcher_factory_(factory),
retry_number_(0),
second_access_token_request_(false) {
DCHECK(token_service);
@@ -126,8 +149,7 @@ void UbertokenFetcher::RequestAccessToken() {
}
void UbertokenFetcher::ExchangeTokens() {
- gaia_auth_fetcher_.reset(new GaiaAuthFetcher(this,
- source_,
- request_context_));
+ gaia_auth_fetcher_.reset(
+ gaia_auth_fetcher_factory_.Run(this, source_, request_context_));
gaia_auth_fetcher_->StartTokenFetchForUberAuthExchange(access_token_);
}
diff --git a/google_apis/gaia/ubertoken_fetcher.h b/google_apis/gaia/ubertoken_fetcher.h
index c74aa6c..ade53cc 100644
--- a/google_apis/gaia/ubertoken_fetcher.h
+++ b/google_apis/gaia/ubertoken_fetcher.h
@@ -26,6 +26,11 @@ namespace net {
class URLRequestContextGetter;
}
+typedef base::Callback<GaiaAuthFetcher*(GaiaAuthConsumer*,
+ const std::string&,
+ net::URLRequestContextGetter*)>
+ GaiaAuthFetcherFactory;
+
// Callback for the |UbertokenFetcher| class.
class UbertokenConsumer {
public:
@@ -46,6 +51,11 @@ class UbertokenFetcher : public GaiaAuthConsumer,
UbertokenConsumer* consumer,
const std::string& source,
net::URLRequestContextGetter* request_context);
+ UbertokenFetcher(OAuth2TokenService* token_service,
+ UbertokenConsumer* consumer,
+ const std::string& source,
+ net::URLRequestContextGetter* request_context,
+ GaiaAuthFetcherFactory factory);
~UbertokenFetcher() override;
// Start fetching the token for |account_id|.
@@ -75,6 +85,7 @@ class UbertokenFetcher : public GaiaAuthConsumer,
UbertokenConsumer* consumer_;
std::string source_;
net::URLRequestContextGetter* request_context_;
+ GaiaAuthFetcherFactory gaia_auth_fetcher_factory_;
scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
scoped_ptr<OAuth2TokenService::Request> access_token_request_;
std::string account_id_;