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

Unified Diff: chrome/browser/extensions/api/identity/identity_api.cc

Issue 2673443002: Remove IdentityGetAuthTokenFunction interface dep on IdentityAPI (Closed)
Patch Set: Created 3 years, 11 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/extensions/api/identity/identity_api.cc
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc
index f0ee21958b983b0ce2fb58fa6c194f17f13423ab..4b74c3fe3091562a2cdfa3c8fab47451caee05a5 100644
--- a/chrome/browser/extensions/api/identity/identity_api.cc
+++ b/chrome/browser/extensions/api/identity/identity_api.cc
@@ -143,7 +143,8 @@ IdentityAPI::IdentityAPI(content::BrowserContext* context)
LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(
Profile::FromBrowserContext(context))),
account_tracker_(&profile_identity_provider_,
- g_browser_process->system_request_context()) {
+ g_browser_process->system_request_context()),
+ get_auth_token_function_(nullptr) {
account_tracker_.AddObserver(this);
}
@@ -207,8 +208,8 @@ std::string IdentityAPI::FindAccountKeyByGaiaId(const std::string& gaia_id) {
}
void IdentityAPI::Shutdown() {
- for (auto& observer : shutdown_observer_list_)
- observer.OnShutdown();
+ if (get_auth_token_function_)
+ get_auth_token_function_->Shutdown();
account_tracker_.RemoveObserver(this);
account_tracker_.Shutdown();
}
@@ -242,14 +243,6 @@ void IdentityAPI::OnAccountSignInChanged(const gaia::AccountIds& ids,
EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
}
-void IdentityAPI::AddShutdownObserver(ShutdownObserver* observer) {
- shutdown_observer_list_.AddObserver(observer);
-}
-
-void IdentityAPI::RemoveShutdownObserver(ShutdownObserver* observer) {
- shutdown_observer_list_.RemoveObserver(observer);
-}
-
void IdentityAPI::SetAccountStateForTest(gaia::AccountIds ids,
bool is_signed_in) {
account_tracker_.SetAccountStateForTest(ids, is_signed_in);
@@ -408,13 +401,13 @@ void IdentityGetAuthTokenFunction::StartAsyncRun() {
AddRef();
extensions::IdentityAPI::GetFactoryInstance()
->Get(GetProfile())
- ->AddShutdownObserver(this);
+ ->set_get_auth_token_function(this);
}
void IdentityGetAuthTokenFunction::CompleteAsyncRun(bool success) {
extensions::IdentityAPI::GetFactoryInstance()
->Get(GetProfile())
- ->RemoveShutdownObserver(this);
+ ->set_get_auth_token_function(nullptr);
SendResponse(success);
Release(); // Balanced in StartAsyncRun
@@ -746,7 +739,7 @@ void IdentityGetAuthTokenFunction::OnGetTokenFailure(
OnGaiaFlowFailure(GaiaWebAuthFlow::SERVICE_AUTH_ERROR, error, std::string());
}
-void IdentityGetAuthTokenFunction::OnShutdown() {
+void IdentityGetAuthTokenFunction::Shutdown() {
gaia_web_auth_flow_.reset();
signin_flow_.reset();
login_token_request_.reset();
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.h ('k') | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698