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

Unified Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.cc

Issue 12380006: Build a new TokenCacheService so I can stop using TokenService for something it wasn't designed for. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Token Cache - CR changes per DCheng and ATWilson Created 7 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/api/push_messaging/push_messaging_api.cc
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
index 07ca1d32f81878ebb3176b5d1fd0d46711fdc3cf..20c5cb97759512b15fd74d974026c8ed3f342283 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
@@ -12,6 +12,8 @@
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.h"
+#include "chrome/browser/extensions/api/token_cache/token_cache.h"
+#include "chrome/browser/extensions/api/token_cache/token_cache_factory.h"
#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -125,15 +127,20 @@ bool PushMessagingGetChannelIdFunction::StartGaiaIdFetch() {
token_service->GetOAuth2LoginRefreshToken();
fetcher_.reset(new ObfuscatedGaiaIdFetcher(context, this, refresh_token));
+ // Get the token cache and see if we have already cached a Gaia Id.
+ TokenCacheService* token_cache =
+ TokenCacheServiceFactory::GetForProfile(profile());
+
// Check the cache, if we already have a gaia ID, use it instead of
// fetching the ID over the network.
const std::string& gaia_id =
- token_service->GetTokenForService(GaiaConstants::kObfuscatedGaiaId);
+ token_cache->RetrieveToken(GaiaConstants::kObfuscatedGaiaId);
if (!gaia_id.empty()) {
ReportResult(gaia_id, std::string());
return true;
}
+
dcheng 2013/03/04 22:40:59 Remove newline?
Pete Williamson 2013/03/05 19:42:25 Done.
fetcher_->Start();
// Will finish asynchronously.
@@ -173,11 +180,10 @@ void PushMessagingGetChannelIdFunction::ReportResult(
// Cache the obfuscated ID locally. It never changes for this user,
// and if we call the web API too often, we get errors due to rate limiting.
if (!gaia_id.empty()) {
- TokenService* token_service = TokenServiceFactory::GetForProfile(profile());
- if (token_service) {
- token_service->AddAuthTokenManually(GaiaConstants::kObfuscatedGaiaId,
- gaia_id);
- }
+ TokenCacheService* token_cache =
+ TokenCacheServiceFactory::GetForProfile(profile());
+ token_cache->StoreToken(GaiaConstants::kObfuscatedGaiaId, gaia_id,
+ GaiaConstants::kObfuscatedGaiaIdTimeout);
}
// Balanced in RunImpl.

Powered by Google App Engine
This is Rietveld 408576698