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

Unified Diff: components/signin/core/browser/profile_oauth2_token_service.cc

Issue 1143323005: Refactor AO2TS to make it easier to componentize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor AO2TS to make it easier to componentize. Created 5 years, 7 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: components/signin/core/browser/profile_oauth2_token_service.cc
diff --git a/components/signin/core/browser/profile_oauth2_token_service.cc b/components/signin/core/browser/profile_oauth2_token_service.cc
index 0de1e2b6ded4e1848305cf2f9531007fce7b408d..a8a291a3b7cc26a278c48e163a4b910d1454c064 100644
--- a/components/signin/core/browser/profile_oauth2_token_service.cc
+++ b/components/signin/core/browser/profile_oauth2_token_service.cc
@@ -4,74 +4,45 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/stl_util.h"
-#include "base/time/time.h"
-#include "components/signin/core/browser/signin_client.h"
-#include "components/signin/core/browser/signin_error_controller.h"
-#include "google_apis/gaia/gaia_auth_util.h"
+#include "google_apis/gaia/oauth2_token_service_delegate.h"
#include "net/url_request/url_request_context_getter.h"
-ProfileOAuth2TokenService::ProfileOAuth2TokenService()
- : client_(NULL),
- signin_error_controller_(NULL) {}
+ProfileOAuth2TokenService::ProfileOAuth2TokenService(
+ OAuth2TokenServiceDelegate* delegate)
+ : OAuth2TokenService(delegate) {
+}
ProfileOAuth2TokenService::~ProfileOAuth2TokenService() {}
-void ProfileOAuth2TokenService::Initialize(
- SigninClient* client,
- SigninErrorController* signin_error_controller) {
- DCHECK(client);
- DCHECK(!client_);
- DCHECK(signin_error_controller);
- DCHECK(!signin_error_controller_);
- client_ = client;
- signin_error_controller_ = signin_error_controller;
-}
-
void ProfileOAuth2TokenService::Shutdown() {
- DCHECK(client_) << "Shutdown() called without matching call to Initialize()";
+ CancelAllRequests();
+ GetDelegate()->Shutdown();
}
net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() {
- return NULL;
-}
-
-void ProfileOAuth2TokenService::UpdateAuthError(
- const std::string& account_id,
- const GoogleServiceAuthError& error) {
- NOTREACHED();
-}
-
-void ProfileOAuth2TokenService::ValidateAccountId(
- const std::string& account_id) const {
- DCHECK(!account_id.empty());
-
- // If the account is given as an email, make sure its a canonical email.
- // Note that some tests don't use email strings as account id, and after
- // the gaia id migration it won't be an email. So only check for
- // canonicalization if the account_id is suspected to be an email.
- if (account_id.find('@') != std::string::npos)
- DCHECK_EQ(gaia::CanonicalizeEmail(account_id), account_id);
-}
-
-std::vector<std::string> ProfileOAuth2TokenService::GetAccounts() {
- NOTREACHED();
- return std::vector<std::string>();
+ return GetDelegate()->GetRequestContext();
}
void ProfileOAuth2TokenService::LoadCredentials(
const std::string& primary_account_id) {
- // Empty implementation by default.
+ CancelAllRequests();
+ GetDelegate()->LoadCredentials(primary_account_id);
}
void ProfileOAuth2TokenService::UpdateCredentials(
const std::string& account_id,
const std::string& refresh_token) {
- NOTREACHED();
-}
-
-void ProfileOAuth2TokenService::RevokeAllCredentials() {
- // Empty implementation by default.
-}
+ std::string present_refresh_token =
+ GetDelegate()->GetRefreshToken(account_id);
+ if (!present_refresh_token.empty() &&
+ present_refresh_token == refresh_token) {
+ CancelRequestsForAccount(account_id);
+ ClearCacheForAccount(account_id);
+ }
Roger Tawa OOO till Jul 10th 2015/05/24 21:13:18 Should always cancel requests and clear the cache
gogerald1 2015/05/25 21:10:57 what if the update credential is the current crede
Roger Tawa OOO till Jul 10th 2015/05/28 14:54:43 Acknowledged.
+ GetDelegate()->UpdateCredentials(account_id, refresh_token);
+}
+
+void ProfileOAuth2TokenService::RevokeCredentials(
+ const std::string& account_id) {
+ GetDelegate()->RevokeCredentials(account_id);
+}

Powered by Google App Engine
This is Rietveld 408576698