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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_factory.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add \n Created 5 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/push_messaging/push_messaging_service_factory.h" 5 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
6 6
7 #include "chrome/browser/profiles/incognito_helpers.h" 7 #include "chrome/browser/profiles/incognito_helpers.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 9 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
10 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 10 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 11 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" 12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 13
14 // static 14 // static
15 PushMessagingServiceImpl* PushMessagingServiceFactory::GetForProfile( 15 PushMessagingServiceImpl* PushMessagingServiceFactory::GetForProfile(
16 content::BrowserContext* profile) { 16 content::BrowserContext* profile) {
17 // The Push API is not currently supported in incognito mode. 17 // The Push API is not currently supported in incognito mode.
18 // See https://crbug.com/401439. 18 // See https://crbug.com/401439.
19 if (profile->IsOffTheRecord()) 19 if (profile->IsOffTheRecord())
20 return NULL; 20 return NULL;
21 21
22 return static_cast<PushMessagingServiceImpl*>( 22 return static_cast<PushMessagingServiceImpl*>(
23 GetInstance()->GetServiceForBrowserContext(profile, true)); 23 GetInstance()->GetServiceForBrowserContext(profile, true));
24 } 24 }
25 25
26 // static 26 // static
27 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() { 27 PushMessagingServiceFactory* PushMessagingServiceFactory::GetInstance() {
28 return Singleton<PushMessagingServiceFactory>::get(); 28 return base::Singleton<PushMessagingServiceFactory>::get();
29 } 29 }
30 30
31 PushMessagingServiceFactory::PushMessagingServiceFactory() 31 PushMessagingServiceFactory::PushMessagingServiceFactory()
32 : BrowserContextKeyedServiceFactory( 32 : BrowserContextKeyedServiceFactory(
33 "PushMessagingProfileService", 33 "PushMessagingProfileService",
34 BrowserContextDependencyManager::GetInstance()) { 34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); 35 DependsOn(gcm::GCMProfileServiceFactory::GetInstance());
36 } 36 }
37 37
38 PushMessagingServiceFactory::~PushMessagingServiceFactory() { 38 PushMessagingServiceFactory::~PushMessagingServiceFactory() {
39 } 39 }
40 40
41 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor( 41 KeyedService* PushMessagingServiceFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const { 42 content::BrowserContext* context) const {
43 Profile* profile = Profile::FromBrowserContext(context); 43 Profile* profile = Profile::FromBrowserContext(context);
44 CHECK(!profile->IsOffTheRecord()); 44 CHECK(!profile->IsOffTheRecord());
45 return new PushMessagingServiceImpl(profile); 45 return new PushMessagingServiceImpl(profile);
46 } 46 }
47 47
48 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse( 48 content::BrowserContext* PushMessagingServiceFactory::GetBrowserContextToUse(
49 content::BrowserContext* context) const { 49 content::BrowserContext* context) const {
50 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 50 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
51 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698