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..34227f701a68aa0a1e2083f1b224b82da855b8f5 100644 |
| --- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc |
| +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc |
| @@ -22,6 +22,8 @@ |
| #include "chrome/browser/signin/token_service_factory.h" |
|
dcheng
2013/02/28 19:18:04
Seems like we don't need these includes anymore.
Pete Williamson
2013/03/04 18:32:53
Nope, these are still used elsewhere (StartGaiaIdF
|
| #include "chrome/browser/sync/profile_sync_service.h" |
| #include "chrome/browser/sync/profile_sync_service_factory.h" |
| +#include "chrome/browser/token_cache/token_cache.h" |
| +#include "chrome/browser/token_cache/token_cache_factory.h" |
| #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/extensions/api/push_messaging.h" |
| @@ -125,13 +127,18 @@ bool PushMessagingGetChannelIdFunction::StartGaiaIdFetch() { |
| token_service->GetOAuth2LoginRefreshToken(); |
| fetcher_.reset(new ObfuscatedGaiaIdFetcher(context, this, refresh_token)); |
| - // 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); |
| - if (!gaia_id.empty()) { |
| - ReportResult(gaia_id, std::string()); |
| - return true; |
| + // Get the token cache and see if we have already cached a Gaia Id. |
| + TokenCacheService* token_cache = |
| + TokenCacheServiceFactory::GetForProfile(profile()); |
| + if (token_cache != NULL) { |
|
dcheng
2013/02/28 19:18:04
Why would this be NULL?
Pete Williamson
2013/03/04 18:32:53
I was thinking out of memory in the token cache se
|
| + // 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_cache->RetrieveToken(GaiaConstants::kObfuscatedGaiaId); |
| + if (!gaia_id.empty()) { |
| + ReportResult(gaia_id, std::string()); |
| + return true; |
| + } |
| } |
| fetcher_->Start(); |
| @@ -173,10 +180,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); |
| + TokenCacheService* token_cache = |
| + TokenCacheServiceFactory::GetForProfile(profile()); |
| + if (token_cache) { |
|
dcheng
2013/02/28 19:18:04
Ditto. Why would this be NULL?
Pete Williamson
2013/03/04 18:32:53
Done.
|
| + token_cache->StoreToken(GaiaConstants::kObfuscatedGaiaId, gaia_id, |
| + GaiaConstants::kObfuscatedGaiaIdTimeout); |
| } |
| } |