Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3129)

Unified Diff: chrome/browser/signin/oauth2_token_service.h

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/oauth2_token_service.h
diff --git a/chrome/browser/signin/oauth2_token_service.h b/chrome/browser/signin/oauth2_token_service.h
index 1d335ccd801488af56bf3c4ae6a1f21be7ca5618..ac993de001916063142bee3387969c2109114ab1 100644
--- a/chrome/browser/signin/oauth2_token_service.h
+++ b/chrome/browser/signin/oauth2_token_service.h
@@ -14,6 +14,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/threading/non_thread_safe.h"
#include "base/time/time.h"
#include "google_apis/gaia/google_service_auth_error.h"
@@ -49,7 +50,7 @@ class GoogleServiceAuthError;
//
// The caller of StartRequest() owns the returned request and is responsible to
// delete the request even once the callback has been invoked.
-class OAuth2TokenService {
+class OAuth2TokenService : public base::NonThreadSafe {
public:
// Class representing a request that fetches an OAuth2 access token.
class Request {
@@ -113,13 +114,15 @@ class OAuth2TokenService {
// |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 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
// Chrome's default values.
- virtual scoped_ptr<Request> StartRequestForClient(
+ scoped_ptr<Request> StartRequestForClient(
const std::string& client_id,
const std::string& client_secret,
const ScopeSet& scopes,
@@ -128,7 +131,7 @@ class OAuth2TokenService {
// This method does the same as |StartRequest| except it uses the request
// context given by |getter| instead of using the one returned by
// |GetRequestContext| implemented by derived classes.
- virtual scoped_ptr<Request> StartRequestWithContext(
+ scoped_ptr<Request> StartRequestWithContext(
net::URLRequestContextGetter* getter,
const ScopeSet& scopes,
Consumer* consumer);
@@ -190,8 +193,9 @@ class OAuth2TokenService {
// Posts a task to fire the Consumer callback with the cached token. Must
// Must only be called if HasCacheEntry() returns true.
- scoped_ptr<Request> StartCacheLookupRequest(const ScopeSet& scopes,
- Consumer* consumer);
+ void StartCacheLookupRequest(RequestImpl* request,
+ const ScopeSet& scopes,
+ Consumer* consumer);
// Clears the internal token cache.
void ClearCache();
@@ -208,11 +212,19 @@ class OAuth2TokenService {
void FireRefreshTokensLoaded();
void FireRefreshTokensCleared();
- private:
// Derived classes must provide a request context used for fetching access
// tokens with the |StartRequest| method.
virtual net::URLRequestContextGetter* GetRequestContext() = 0;
+ // 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,
+ net::URLRequestContextGetter* getter,
+ const std::string& client_id,
+ const std::string& client_secret,
+ const ScopeSet& scopes);
+
+ private:
// Class that fetches an OAuth2 access token for a given set of scopes and
// OAuth2 refresh token.
class Fetcher;
« no previous file with comments | « chrome/browser/signin/fake_profile_oauth2_token_service.cc ('k') | chrome/browser/signin/oauth2_token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698