Chromium Code Reviews| 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..cbe133b58cd59230d23582630c1fee38713e9d78 100644 |
| --- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc |
| +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc |
| @@ -17,6 +17,8 @@ |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_system.h" |
| #include "chrome/browser/extensions/extension_system_factory.h" |
| +#include "chrome/browser/extensions/token_cache/token_cache.h" |
| +#include "chrome/browser/extensions/token_cache/token_cache_factory.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/signin/token_service.h" |
| #include "chrome/browser/signin/token_service_factory.h" |
| @@ -125,10 +127,14 @@ 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; |
| @@ -173,11 +179,11 @@ 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); |
| - } |
| + int timeoutDays = GaiaConstants::kObfuscatedGaiaIdTimeoutInDays; |
|
dcheng
2013/03/05 22:38:44
Naming is incorrect. Also, I'd suggest just doing
Pete Williamson
2013/03/06 00:09:40
Done.
|
| + TokenCacheService* token_cache = |
| + TokenCacheServiceFactory::GetForProfile(profile()); |
| + token_cache->StoreToken(GaiaConstants::kObfuscatedGaiaId, gaia_id, |
| + base::TimeDelta::FromDays(timeoutDays)); |
| } |
| // Balanced in RunImpl. |