diff options
author | fgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-26 05:29:10 +0000 |
---|---|---|
committer | fgorski@chromium.org <fgorski@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-26 05:29:10 +0000 |
commit | 63a9addb34be168995e913bb0ed40bfd8e569372 (patch) | |
tree | 8a7e831dd55bdddd1da92ab32b54633b88f62828 /google_apis | |
parent | ccf70aa252a1921db9c678b68b0d77ab035a4ff8 (diff) | |
download | chromium_src-63a9addb34be168995e913bb0ed40bfd8e569372.zip chromium_src-63a9addb34be168995e913bb0ed40bfd8e569372.tar.gz chromium_src-63a9addb34be168995e913bb0ed40bfd8e569372.tar.bz2 |
Removing StartRequest override from DO2TS and virtual keyword from O2TS.StartRequest
* Removing virtual keyword from OAuth2TokenService.StartRequest
* Introducing virtual CreateRequest in OAuth2TokenService to allow derive classes to control the creation of Requests
* Overriding CreateRequest in DeviceOAuth2TokenService with a wrapper over the Consumer, so that the refresh token can be validated by ValidatingConsumer, before it is passed on to the actual consumer.
BUG=282454
Review URL: https://codereview.chromium.org/23850010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/oauth2_token_service.cc | 7 | ||||
-rw-r--r-- | google_apis/gaia/oauth2_token_service.h | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/google_apis/gaia/oauth2_token_service.cc b/google_apis/gaia/oauth2_token_service.cc index 3259e28..fe5e004 100644 --- a/google_apis/gaia/oauth2_token_service.cc +++ b/google_apis/gaia/oauth2_token_service.cc @@ -445,7 +445,7 @@ OAuth2TokenService::StartRequestForClientWithContext( Consumer* consumer) { DCHECK(CalledOnValidThread()); - scoped_ptr<RequestImpl> request(new RequestImpl(consumer)); + scoped_ptr<RequestImpl> request = CreateRequest(consumer); if (!RefreshTokenIsAvailable(account_id)) { base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( @@ -473,6 +473,11 @@ OAuth2TokenService::StartRequestForClientWithContext( return request.PassAs<Request>(); } +scoped_ptr<OAuth2TokenService::RequestImpl> OAuth2TokenService::CreateRequest( + Consumer* consumer) { + return scoped_ptr<RequestImpl>(new RequestImpl(consumer)); +} + void OAuth2TokenService::FetchOAuth2Token(RequestImpl* request, const std::string& account_id, net::URLRequestContextGetter* getter, diff --git a/google_apis/gaia/oauth2_token_service.h b/google_apis/gaia/oauth2_token_service.h index d092430..b8faecd 100644 --- a/google_apis/gaia/oauth2_token_service.h +++ b/google_apis/gaia/oauth2_token_service.h @@ -111,11 +111,9 @@ class OAuth2TokenService : public base::NonThreadSafe { // |scopes| is the set of scopes to get an access token for, |consumer| is // the object that will be called back with results if the returned request // is not deleted. - // TODO(atwilson): Make this non-virtual when we change - // ProfileOAuth2TokenServiceRequestTest to use FakeProfileOAuth2TokenService. - virtual scoped_ptr<Request> StartRequest(const std::string& account_id, - const ScopeSet& scopes, - Consumer* consumer); + scoped_ptr<Request> StartRequest(const std::string& account_id, + const ScopeSet& scopes, + Consumer* consumer); // This method does the same as |StartRequest| except it uses |client_id| and // |client_secret| to identify OAuth client app instead of using @@ -229,6 +227,11 @@ class OAuth2TokenService : public base::NonThreadSafe { void FireRefreshTokenRevoked(const std::string& account_id); void FireRefreshTokensLoaded(); + // Creates a request implementation. Can be overriden by derived classes to + // provide additional control of token consumption. |consumer| will outlive + // the created request. + virtual scoped_ptr<RequestImpl> CreateRequest(Consumer* consumer); + // Fetches an OAuth token for the specified client/scopes. Virtual so it can // be overridden for tests and for platform-specific behavior on Android. virtual void FetchOAuth2Token(RequestImpl* request, |