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

Unified Diff: chrome/browser/extensions/token_cache/token_cache_service.cc

Issue 170383005: Move TokenCacheService away from listening for Signin notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call Shutdown() in unit test Created 6 years, 10 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/token_cache/token_cache_service.cc
diff --git a/chrome/browser/extensions/token_cache/token_cache_service.cc b/chrome/browser/extensions/token_cache/token_cache_service.cc
index 9d5aabd3b403aa91c6d5ba9060fa497cf85a91ca..65938beae4aaa2e7ffb8f9c3ebe2b0278526929e 100644
--- a/chrome/browser/extensions/token_cache/token_cache_service.cc
+++ b/chrome/browser/extensions/token_cache/token_cache_service.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/extensions/token_cache/token_cache_service.h"
#include "base/logging.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "content/public/browser/notification_source.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
using base::Time;
using base::TimeDelta;
@@ -14,9 +14,7 @@ using base::TimeDelta;
namespace extensions {
TokenCacheService::TokenCacheService(Profile* profile) : profile_(profile) {
- registrar_.Add(this,
- chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
- content::Source<Profile>(profile_));
+ SigninManagerFactory::GetForProfile(profile)->AddObserver(this);
}
TokenCacheService::~TokenCacheService() {
@@ -67,11 +65,12 @@ std::string TokenCacheService::RetrieveToken(const std::string& token_name) {
return std::string();
}
-// Inherited from NotificationObserver.
-void TokenCacheService::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT == type);
+void TokenCacheService::Shutdown() {
+ SigninManagerFactory::GetForProfile(const_cast<Profile*>(profile_))
+ ->RemoveObserver(this);
+}
+
+void TokenCacheService::GoogleSignedOut(const std::string& username) {
token_cache_.clear();
}

Powered by Google App Engine
This is Rietveld 408576698