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

Unified Diff: chrome/browser/chromeos/login/signin/token_handle_fetcher.cc

Issue 1294543008: ChromeOS: fix crash in TokenHandleFetcher destructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « chrome/browser/chromeos/login/signin/token_handle_fetcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
diff --git a/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc b/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
index 8d2f50ccc10f598558da55669330a2f7f665a994..c7ee2ae527245570d2aa4ba3a2bc809f6615db99 100644
--- a/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
+++ b/chrome/browser/chromeos/login/signin/token_handle_fetcher.cc
@@ -11,12 +11,34 @@
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
+#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/gaia_constants.h"
namespace {
const int kMaxRetries = 3;
+
+class ShutdownNotifierFactory
+ : public BrowserContextKeyedServiceShutdownNotifierFactory {
+ public:
+ static ShutdownNotifierFactory* GetInstance() {
+ return Singleton<ShutdownNotifierFactory>::get();
+ }
+
+ private:
+ friend struct DefaultSingletonTraits<ShutdownNotifierFactory>;
+
+ ShutdownNotifierFactory()
+ : BrowserContextKeyedServiceShutdownNotifierFactory(
+ "TokenHandleFetcher") {
+ DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
+ }
+ ~ShutdownNotifierFactory() override {}
+
+ DISALLOW_COPY_AND_ASSIGN(ShutdownNotifierFactory);
+};
+
} // namespace
TokenHandleFetcher::TokenHandleFetcher(TokenHandleUtil* util,
@@ -46,6 +68,11 @@ void TokenHandleFetcher::BackfillToken(Profile* profile,
std::string account_id = signin_manager->GetAuthenticatedAccountId();
if (!token_service_->RefreshTokenIsAvailable(account_id)) {
account_without_token_ = account_id;
+ profile_shutdown_notification_ =
+ ShutdownNotifierFactory::GetInstance()->Get(profile)->Subscribe(
+ base::Bind(&TokenHandleFetcher::OnProfileDestroyed,
+ base::Unretained(this)));
+
token_service_->AddObserver(this);
waiting_for_refresh_token_ = true;
return;
@@ -124,3 +151,7 @@ void TokenHandleFetcher::OnGetTokenInfoResponse(
UMA_HISTOGRAM_TIMES("Login.TokenObtainResponseTime", duration);
callback_.Run(user_id_, success);
}
+
+void TokenHandleFetcher::OnProfileDestroyed() {
+ callback_.Run(user_id_, false);
+}
« no previous file with comments | « chrome/browser/chromeos/login/signin/token_handle_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698