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

Side by Side Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.cc

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 // GetChannelId class functions 85 // GetChannelId class functions
86 86
87 PushMessagingGetChannelIdFunction::PushMessagingGetChannelIdFunction() 87 PushMessagingGetChannelIdFunction::PushMessagingGetChannelIdFunction()
88 : OAuth2TokenService::Consumer("push_messaging"), 88 : OAuth2TokenService::Consumer("push_messaging"),
89 interactive_(false) {} 89 interactive_(false) {}
90 90
91 PushMessagingGetChannelIdFunction::~PushMessagingGetChannelIdFunction() {} 91 PushMessagingGetChannelIdFunction::~PushMessagingGetChannelIdFunction() {}
92 92
93 bool PushMessagingGetChannelIdFunction::RunImpl() { 93 bool PushMessagingGetChannelIdFunction::RunAsync() {
94 // Fetch the function arguments. 94 // Fetch the function arguments.
95 scoped_ptr<glue::GetChannelId::Params> params( 95 scoped_ptr<glue::GetChannelId::Params> params(
96 glue::GetChannelId::Params::Create(*args_)); 96 glue::GetChannelId::Params::Create(*args_));
97 EXTENSION_FUNCTION_VALIDATE(params.get()); 97 EXTENSION_FUNCTION_VALIDATE(params.get());
98 98
99 if (params && params->interactive) { 99 if (params && params->interactive) {
100 interactive_ = *params->interactive; 100 interactive_ = *params->interactive;
101 } 101 }
102 102
103 // Balanced in ReportResult() 103 // Balanced in ReportResult()
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // and if we call the web API too often, we get errors due to rate limiting. 215 // and if we call the web API too often, we get errors due to rate limiting.
216 if (!gaia_id.empty()) { 216 if (!gaia_id.empty()) {
217 base::TimeDelta timeout = 217 base::TimeDelta timeout =
218 base::TimeDelta::FromDays(kObfuscatedGaiaIdTimeoutInDays); 218 base::TimeDelta::FromDays(kObfuscatedGaiaIdTimeoutInDays);
219 TokenCacheService* token_cache = 219 TokenCacheService* token_cache =
220 TokenCacheServiceFactory::GetForProfile(GetProfile()); 220 TokenCacheServiceFactory::GetForProfile(GetProfile());
221 token_cache->StoreToken(GaiaConstants::kObfuscatedGaiaId, gaia_id, 221 token_cache->StoreToken(GaiaConstants::kObfuscatedGaiaId, gaia_id,
222 timeout); 222 timeout);
223 } 223 }
224 224
225 // Balanced in RunImpl. 225 // Balanced in RunAsync.
226 Release(); 226 Release();
227 } 227 }
228 228
229 void PushMessagingGetChannelIdFunction::BuildAndSendResult( 229 void PushMessagingGetChannelIdFunction::BuildAndSendResult(
230 const std::string& gaia_id, const std::string& error_message) { 230 const std::string& gaia_id, const std::string& error_message) {
231 std::string channel_id; 231 std::string channel_id;
232 if (!gaia_id.empty()) { 232 if (!gaia_id.empty()) {
233 channel_id = gaia_id; 233 channel_id = gaia_id;
234 channel_id += kChannelIdSeparator; 234 channel_id += kChannelIdSeparator;
235 channel_id += extension_id(); 235 channel_id += extension_id();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 369
370 template <> 370 template <>
371 void 371 void
372 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { 372 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() {
373 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 373 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
374 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); 374 DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
375 } 375 }
376 376
377 } // namespace extensions 377 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698