Index: google_apis/gaia/oauth2_token_service.h |
diff --git a/google_apis/gaia/oauth2_token_service.h b/google_apis/gaia/oauth2_token_service.h |
index 2306c1031024716f71ca562be70174e57c944fdc..177f0e05d3f47a14c0a0c8813ae4c80df73743dc 100644 |
--- a/google_apis/gaia/oauth2_token_service.h |
+++ b/google_apis/gaia/oauth2_token_service.h |
@@ -26,6 +26,7 @@ class URLRequestContextGetter; |
class GoogleServiceAuthError; |
class OAuth2AccessTokenFetcher; |
+class OAuth2TokenServiceDelegate; |
// Abstract base class for a service that fetches and caches OAuth2 access |
// tokens. Concrete subclasses should implement GetRefreshToken to return |
@@ -129,7 +130,7 @@ class OAuth2TokenService : public base::NonThreadSafe { |
const ScopeSet& scopes) = 0; |
}; |
- OAuth2TokenService(); |
+ OAuth2TokenService(OAuth2TokenServiceDelegate* delegate); |
virtual ~OAuth2TokenService(); |
// Add or remove observers of this token service. |
@@ -172,11 +173,14 @@ class OAuth2TokenService : public base::NonThreadSafe { |
// Lists account IDs of all accounts with a refresh token maintained by this |
// instance. |
- virtual std::vector<std::string> GetAccounts(); |
+ virtual std::vector<std::string> GetAccounts(); // ganggui_temp |
// Returns true if a refresh token exists for |account_id|. If false, calls to |
// |StartRequest| will result in a Consumer::OnGetTokenFailure callback. |
- virtual bool RefreshTokenIsAvailable(const std::string& account_id) const = 0; |
+ virtual bool RefreshTokenIsAvailable( |
+ const std::string& account_id) const; // ganggui_temp |
Roger Tawa OOO till Jul 10th
2015/05/24 21:13:18
The above two methods should not be virtual. Is t
gogerald1
2015/05/25 21:10:58
Done.
gogerald1
2015/05/25 21:10:58
Yes, just make it pass the unit_tests compilation,
|
+ |
+ void RevokeAllCredentials(); |
// Mark an OAuth2 |access_token| issued for |account_id| and |scopes| as |
// invalid. This should be done if the token was received from this class, |
@@ -204,6 +208,16 @@ class OAuth2TokenService : public base::NonThreadSafe { |
const std::string& account_id, |
const ScopeSet& scopes) const; |
+ OAuth2TokenServiceDelegate* GetDelegate(); |
+ |
+ // Invalidates the |access_token| issued for |account_id|, |client_id| and |
+ // |scopes|. Virtual so it can be overriden for tests and for platform- |
+ // specifc behavior. |
+ virtual void InvalidateOAuth2Token(const std::string& account_id, |
+ const std::string& client_id, |
+ const ScopeSet& scopes, |
+ const std::string& access_token); |
Roger Tawa OOO till Jul 10th
2015/05/24 21:13:18
I think this should be made private, otherwise the
gogerald1
2015/05/25 21:10:57
Yes, I will move it into protect group, it was mov
|
+ |
protected: |
// Implements a cancelable |OAuth2TokenService::Request|, which should be |
// operated on the UI thread. |
@@ -232,20 +246,9 @@ class OAuth2TokenService : public base::NonThreadSafe { |
Consumer* const consumer_; |
}; |
- // Helper class to scope batch changes. |
- class ScopedBatchChange { |
- public: |
- explicit ScopedBatchChange(OAuth2TokenService* token_service); |
- ~ScopedBatchChange(); |
- private: |
- OAuth2TokenService* token_service_; // Weak. |
- DISALLOW_COPY_AND_ASSIGN(ScopedBatchChange); |
- }; |
- |
// Subclasses can override if they want to report errors to the user. |
- virtual void UpdateAuthError( |
- const std::string& account_id, |
- const GoogleServiceAuthError& error); |
+ void UpdateAuthError(const std::string& account_id, |
+ const GoogleServiceAuthError& error); |
// Add a new entry to the cache. |
// Subclasses can override if there are implementation-specific reasons |
@@ -270,14 +273,6 @@ class OAuth2TokenService : public base::NonThreadSafe { |
// Cancels all requests related to a given |account_id|. |
void CancelRequestsForAccount(const std::string& account_id); |
- // Called by subclasses to notify observers. |
- virtual void FireRefreshTokenAvailable(const std::string& account_id); |
- virtual void FireRefreshTokenRevoked(const std::string& account_id); |
- virtual void FireRefreshTokensLoaded(); |
- |
- virtual void StartBatchChanges(); |
- virtual void EndBatchChanges(); |
- |
// 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, |
@@ -295,19 +290,12 @@ class OAuth2TokenService : public base::NonThreadSafe { |
virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
const std::string& account_id, |
net::URLRequestContextGetter* getter, |
- OAuth2AccessTokenConsumer* consumer) = 0; |
- |
- // Invalidates the |access_token| issued for |account_id|, |client_id| and |
- // |scopes|. Virtual so it can be overriden for tests and for platform- |
- // specifc behavior. |
- virtual void InvalidateOAuth2Token(const std::string& account_id, |
- const std::string& client_id, |
- const ScopeSet& scopes, |
- const std::string& access_token); |
+ OAuth2AccessTokenConsumer* consumer); // ganggui_temp |
Roger Tawa OOO till Jul 10th
2015/05/24 21:13:18
This should not be virtual.
gogerald1
2015/05/25 21:10:58
Done.
|
private: |
class Fetcher; |
friend class Fetcher; |
+ friend class OAuth2TokenServiceDelegate; |
// The parameters used to fetch an OAuth2 access token. |
struct RequestParameters { |
@@ -379,20 +367,15 @@ class OAuth2TokenService : public base::NonThreadSafe { |
typedef std::map<RequestParameters, CacheEntry> TokenCache; |
TokenCache token_cache_; |
+ scoped_ptr<OAuth2TokenServiceDelegate> delegate_; |
+ |
// A map from fetch parameters to a fetcher that is fetching an OAuth2 access |
// token using these parameters. |
PendingFetcherMap pending_fetchers_; |
- // List of observers to notify when refresh token availability changes. |
- // Makes sure list is empty on destruction. |
- ObserverList<Observer, true> observer_list_; |
- |
// List of observers to notify when access token status changes. |
ObserverList<DiagnosticsObserver, true> diagnostics_observer_list_; |
- // The depth of batch changes. |
- int batch_change_depth_; |
- |
// Maximum number of retries in fetching an OAuth2 access token. |
static int max_fetch_retry_num_; |