OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/services/gcm/gcm_profile_service_factory.h" | 5 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/services/gcm/gcm_profile_service.h" | |
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
12 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
12 #include "chrome/common/channel_info.h" | |
13 #include "components/gcm_driver/gcm_profile_service.h" | |
13 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
15 #include "components/signin/core/browser/signin_manager.h" | |
16 #include "content/public/browser/browser_thread.h" | |
14 | 17 |
15 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 19 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
17 #include "components/gcm_driver/gcm_client_factory.h" | 20 #include "components/gcm_driver/gcm_client_factory.h" |
18 #endif | 21 #endif |
19 | 22 |
20 namespace gcm { | 23 namespace gcm { |
21 | 24 |
22 // static | 25 // static |
23 GCMProfileService* GCMProfileServiceFactory::GetForProfile( | 26 GCMProfileService* GCMProfileServiceFactory::GetForProfile( |
(...skipping 20 matching lines...) Expand all Loading... | |
44 #if !defined(OS_ANDROID) | 47 #if !defined(OS_ANDROID) |
45 DependsOn(LoginUIServiceFactory::GetInstance()); | 48 DependsOn(LoginUIServiceFactory::GetInstance()); |
46 #endif | 49 #endif |
47 } | 50 } |
48 | 51 |
49 GCMProfileServiceFactory::~GCMProfileServiceFactory() { | 52 GCMProfileServiceFactory::~GCMProfileServiceFactory() { |
50 } | 53 } |
51 | 54 |
52 KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( | 55 KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( |
53 content::BrowserContext* context) const { | 56 content::BrowserContext* context) const { |
57 Profile* profile = Profile::FromBrowserContext(context); | |
58 CHECK(!profile->IsOffTheRecord()); | |
59 | |
60 base::SequencedWorkerPool* worker_pool = | |
johnme
2015/10/28 14:34:56
It seems a shame to duplicate this code with exten
droger
2015/10/28 14:41:08
gcm_profile_service_unittest should be componentiz
Jitu( very slow this week)
2015/10/29 14:11:25
I am planning to take componentizing of gcm_profil
droger
2015/10/29 14:18:06
That's fine for me.
| |
61 content::BrowserThread::GetBlockingPool(); | |
62 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | |
63 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | |
64 worker_pool->GetSequenceToken(), | |
65 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | |
54 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
55 return new GCMProfileService(Profile::FromBrowserContext(context)); | 67 return new GCMProfileService(profile->GetPath(), blocking_task_runner); |
56 #else | 68 #else |
57 return new GCMProfileService( | 69 return new GCMProfileService( |
58 Profile::FromBrowserContext(context), | 70 profile->GetPrefs(), profile->GetPath(), profile->GetRequestContext(), |
59 scoped_ptr<GCMClientFactory>(new GCMClientFactory)); | 71 chrome::GetChannel(), SigninManagerFactory::GetForProfile(profile), |
72 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | |
73 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile), | |
74 scoped_ptr<GCMClientFactory>(new GCMClientFactory), | |
75 content::BrowserThread::GetMessageLoopProxyForThread( | |
76 content::BrowserThread::UI), | |
77 content::BrowserThread::GetMessageLoopProxyForThread( | |
78 content::BrowserThread::IO), | |
79 blocking_task_runner); | |
60 #endif | 80 #endif |
61 } | 81 } |
62 | 82 |
63 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( | 83 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( |
64 content::BrowserContext* context) const { | 84 content::BrowserContext* context) const { |
65 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | 85 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
66 } | 86 } |
67 | 87 |
68 } // namespace gcm | 88 } // namespace gcm |
OLD | NEW |