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

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

Issue 13197004: Draft: InvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Passes tests Created 7 years, 8 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h" 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h"
15 #include "chrome/browser/extensions/event_names.h" 15 #include "chrome/browser/extensions/event_names.h"
16 #include "chrome/browser/extensions/event_router.h" 16 #include "chrome/browser/extensions/event_router.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/extension_system_factory.h" 19 #include "chrome/browser/extensions/extension_system_factory.h"
20 #include "chrome/browser/extensions/token_cache/token_cache_service.h" 20 #include "chrome/browser/extensions/token_cache/token_cache_service.h"
21 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h" 21 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h"
22 #include "chrome/browser/invalidation_service.h"
23 #include "chrome/browser/invalidation_service_factory.h"
22 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/signin/token_service.h" 25 #include "chrome/browser/signin/token_service.h"
24 #include "chrome/browser/signin/token_service_factory.h" 26 #include "chrome/browser/signin/token_service_factory.h"
25 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/sync/profile_sync_service_factory.h"
27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
28 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
29 #include "chrome/common/extensions/api/push_messaging.h" 29 #include "chrome/common/extensions/api/push_messaging.h"
30 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
31 #include "chrome/common/extensions/extension_set.h" 31 #include "chrome/common/extensions/extension_set.h"
32 #include "chrome/common/extensions/permissions/api_permission.h" 32 #include "chrome/common/extensions/permissions/api_permission.h"
33 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/notification_details.h" 34 #include "content/public/browser/notification_details.h"
35 #include "content/public/browser/notification_source.h" 35 #include "content/public/browser/notification_source.h"
36 #include "google_apis/gaia/gaia_constants.h" 36 #include "google_apis/gaia/gaia_constants.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 // static 266 // static
267 ProfileKeyedAPIFactory<PushMessagingAPI>* 267 ProfileKeyedAPIFactory<PushMessagingAPI>*
268 PushMessagingAPI::GetFactoryInstance() { 268 PushMessagingAPI::GetFactoryInstance() {
269 return &g_factory.Get(); 269 return &g_factory.Get();
270 } 270 }
271 271
272 void PushMessagingAPI::Observe(int type, 272 void PushMessagingAPI::Observe(int type,
273 const content::NotificationSource& source, 273 const content::NotificationSource& source,
274 const content::NotificationDetails& details) { 274 const content::NotificationDetails& details) {
275 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(profile_); 275 InvalidationService* is = InvalidationServiceFactory::GetForProfile(profile_);
tim (not reviewing) 2013/04/15 16:48:24 nit - |service| would be a better name here, we sh
rlarocque 2013/04/22 21:47:15 Done.
276 // This may be NULL; for example, for the ChromeOS guest user. In these cases, 276 // This may be NULL; for example, for the ChromeOS guest user. In these cases,
277 // just return without setting up anything, since it won't work anyway. 277 // just return without setting up anything, since it won't work anyway.
278 if (!pss) 278 if (!is)
279 return; 279 return;
280 280
281 if (!event_router_) 281 if (!event_router_)
282 event_router_.reset(new PushMessagingEventRouter(profile_)); 282 event_router_.reset(new PushMessagingEventRouter(profile_));
283 if (!handler_) { 283 if (!handler_) {
284 handler_.reset(new PushMessagingInvalidationHandler( 284 handler_.reset(new PushMessagingInvalidationHandler(
285 pss, event_router_.get())); 285 is, event_router_.get()));
286 } 286 }
287 switch (type) { 287 switch (type) {
288 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 288 case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
289 const Extension* extension = content::Details<Extension>(details).ptr(); 289 const Extension* extension = content::Details<Extension>(details).ptr();
290 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { 290 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) {
291 handler_->SuppressInitialInvalidationsForExtension(extension->id()); 291 handler_->SuppressInitialInvalidationsForExtension(extension->id());
292 } 292 }
293 break; 293 break;
294 } 294 }
295 case chrome::NOTIFICATION_EXTENSION_LOADED: { 295 case chrome::NOTIFICATION_EXTENSION_LOADED: {
(...skipping 17 matching lines...) Expand all
313 } 313 }
314 314
315 void PushMessagingAPI::SetMapperForTest( 315 void PushMessagingAPI::SetMapperForTest(
316 scoped_ptr<PushMessagingInvalidationMapper> mapper) { 316 scoped_ptr<PushMessagingInvalidationMapper> mapper) {
317 handler_ = mapper.Pass(); 317 handler_ = mapper.Pass();
318 } 318 }
319 319
320 template <> 320 template <>
321 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { 321 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() {
322 DependsOn(ExtensionSystemFactory::GetInstance()); 322 DependsOn(ExtensionSystemFactory::GetInstance());
323 DependsOn(ProfileSyncServiceFactory::GetInstance()); 323 DependsOn(InvalidationServiceFactory::GetInstance());
324 } 324 }
325 325
326 } // namespace extensions 326 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698