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

Unified Diff: google_apis/gaia/oauth2_token_service_delegate.h

Issue 1143323005: Refactor AO2TS to make it easier to componentize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address final comments Created 5 years, 6 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
« no previous file with comments | « google_apis/gaia/oauth2_token_service.cc ('k') | google_apis/gaia/oauth2_token_service_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/oauth2_token_service_delegate.h
diff --git a/google_apis/gaia/oauth2_token_service_delegate.h b/google_apis/gaia/oauth2_token_service_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..cb38c2eb0e5a3a60a16db7dfbf16129ee71a3da8
--- /dev/null
+++ b/google_apis/gaia/oauth2_token_service_delegate.h
@@ -0,0 +1,87 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
+#define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
+
+#include "base/observer_list.h"
+#include "google_apis/gaia/gaia_auth_util.h"
+#include "google_apis/gaia/oauth2_token_service.h"
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+class SigninClient;
+
+// Abstract base class to fetch and maintain refresh tokens from various
+// entities. Concrete subclasses should implement RefreshTokenIsAvailable and
+// CreateAccessTokenFetcher properly.
+class OAuth2TokenServiceDelegate {
+ public:
+ OAuth2TokenServiceDelegate();
+ virtual ~OAuth2TokenServiceDelegate();
+
+ virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher(
+ const std::string& account_id,
+ net::URLRequestContextGetter* getter,
+ OAuth2AccessTokenConsumer* consumer) = 0;
+
+ virtual bool RefreshTokenIsAvailable(const std::string& account_id) const = 0;
+ virtual void UpdateAuthError(const std::string& account_id,
+ const GoogleServiceAuthError& error){};
+
+ virtual std::vector<std::string> GetAccounts();
+ virtual void RevokeAllCredentials(){};
+
+ virtual void InvalidateAccessToken(const std::string& account_id,
+ const std::string& client_id,
+ const std::set<std::string>& scopes,
+ const std::string& access_token) {}
+
+ virtual void Shutdown() {}
+ virtual void LoadCredentials(const std::string& primary_account_id) {}
+ virtual void UpdateCredentials(const std::string& account_id,
+ const std::string& refresh_token) {}
+ virtual void RevokeCredentials(const std::string& account_id) {}
+ virtual net::URLRequestContextGetter* GetRequestContext() const;
+
+ void ValidateAccountId(const std::string& account_id) const;
+
+ // Add or remove observers of this token service.
+ void AddObserver(OAuth2TokenService::Observer* observer);
+ void RemoveObserver(OAuth2TokenService::Observer* observer);
+
+ protected:
+ // 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();
+
+ // Helper class to scope batch changes.
+ class ScopedBatchChange {
+ public:
+ explicit ScopedBatchChange(OAuth2TokenServiceDelegate* delegate);
+ ~ScopedBatchChange();
+
+ private:
+ OAuth2TokenServiceDelegate* delegate_; // Weak.
+ DISALLOW_COPY_AND_ASSIGN(ScopedBatchChange);
+ };
+
+ private:
+ // List of observers to notify when refresh token availability changes.
+ // Makes sure list is empty on destruction.
+ base::ObserverList<OAuth2TokenService::Observer, true> observer_list_;
+
+ void StartBatchChanges();
+ void EndBatchChanges();
+
+ // The depth of batch changes.
+ int batch_change_depth_;
+
+ DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegate);
+};
+
+#endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
« no previous file with comments | « google_apis/gaia/oauth2_token_service.cc ('k') | google_apis/gaia/oauth2_token_service_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698