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

Unified Diff: google_apis/gaia/fake_oauth2_token_service.cc

Issue 336253002: Add IdentityProvider-based AccountTracker to google_apis (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add pointer ownership comment Created 6 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/fake_oauth2_token_service.h ('k') | google_apis/google_apis.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/fake_oauth2_token_service.cc
diff --git a/google_apis/gaia/fake_oauth2_token_service.cc b/google_apis/gaia/fake_oauth2_token_service.cc
index f23f349726747f45f5a26a8779ef8bac3a4e2616..0b01404bd8735dc2fc45b8d64d4edc458ba2fceb 100644
--- a/google_apis/gaia/fake_oauth2_token_service.cc
+++ b/google_apis/gaia/fake_oauth2_token_service.cc
@@ -4,11 +4,22 @@
#include "google_apis/gaia/fake_oauth2_token_service.h"
-FakeOAuth2TokenService::FakeOAuth2TokenService() : request_context_(NULL) {}
+FakeOAuth2TokenService::PendingRequest::PendingRequest() {
+}
+
+FakeOAuth2TokenService::PendingRequest::~PendingRequest() {
+}
+
+FakeOAuth2TokenService::FakeOAuth2TokenService() : request_context_(NULL) {
+}
FakeOAuth2TokenService::~FakeOAuth2TokenService() {
}
+std::vector<std::string> FakeOAuth2TokenService::GetAccounts() {
+ return std::vector<std::string>(account_ids_.begin(), account_ids_.end());
+}
+
void FakeOAuth2TokenService::FetchOAuth2Token(
RequestImpl* request,
const std::string& account_id,
@@ -16,6 +27,13 @@ void FakeOAuth2TokenService::FetchOAuth2Token(
const std::string& client_id,
const std::string& client_secret,
const ScopeSet& scopes) {
+ PendingRequest pending_request;
+ pending_request.account_id = account_id;
+ pending_request.client_id = client_id;
+ pending_request.client_secret = client_secret;
+ pending_request.scopes = scopes;
+ pending_request.request = request->AsWeakPtr();
+ pending_requests_.push_back(pending_request);
}
void FakeOAuth2TokenService::InvalidateOAuth2Token(
@@ -36,8 +54,30 @@ bool FakeOAuth2TokenService::RefreshTokenIsAvailable(
void FakeOAuth2TokenService::AddAccount(const std::string& account_id) {
account_ids_.insert(account_id);
+ FireRefreshTokenAvailable(account_id);
}
+void FakeOAuth2TokenService::RemoveAccount(const std::string& account_id) {
+ account_ids_.erase(account_id);
+ FireRefreshTokenRevoked(account_id);
+}
+
+void FakeOAuth2TokenService::IssueAllTokensForAccount(
+ const std::string& account_id,
+ const std::string& access_token,
+ const base::Time& expiration) {
+
+ // Walk the requests and notify the callbacks.
+ for (std::vector<PendingRequest>::iterator it = pending_requests_.begin();
+ it != pending_requests_.end(); ++it) {
+ if (it->request && (account_id == it->account_id)) {
+ it->request->InformConsumer(
+ GoogleServiceAuthError::AuthErrorNone(), access_token, expiration);
+ }
+ }
+}
+
+
OAuth2AccessTokenFetcher* FakeOAuth2TokenService::CreateAccessTokenFetcher(
const std::string& account_id,
net::URLRequestContextGetter* getter,
« no previous file with comments | « google_apis/gaia/fake_oauth2_token_service.h ('k') | google_apis/google_apis.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698