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

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service_factory.cc

Issue 1425783002: Componentizing GcmProfileService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UT errors as per comments Created 5 years, 1 month 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 (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/profile_identity_provider.h"
16 #include "components/signin/core/browser/signin_manager.h"
17 #include "content/public/browser/browser_thread.h"
14 18
15 #if !defined(OS_ANDROID) 19 #if !defined(OS_ANDROID)
16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 20 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
17 #include "components/gcm_driver/gcm_client_factory.h" 21 #include "components/gcm_driver/gcm_client_factory.h"
18 #endif 22 #endif
19 23
20 namespace gcm { 24 namespace gcm {
21 25
22 // static 26 // static
23 GCMProfileService* GCMProfileServiceFactory::GetForProfile( 27 GCMProfileService* GCMProfileServiceFactory::GetForProfile(
(...skipping 20 matching lines...) Expand all
44 #if !defined(OS_ANDROID) 48 #if !defined(OS_ANDROID)
45 DependsOn(LoginUIServiceFactory::GetInstance()); 49 DependsOn(LoginUIServiceFactory::GetInstance());
46 #endif 50 #endif
47 } 51 }
48 52
49 GCMProfileServiceFactory::~GCMProfileServiceFactory() { 53 GCMProfileServiceFactory::~GCMProfileServiceFactory() {
50 } 54 }
51 55
52 KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( 56 KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
53 content::BrowserContext* context) const { 57 content::BrowserContext* context) const {
58 Profile* profile = Profile::FromBrowserContext(context);
59 DCHECK(!profile->IsOffTheRecord());
60
61 base::SequencedWorkerPool* worker_pool =
62 content::BrowserThread::GetBlockingPool();
63 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner(
64 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
65 worker_pool->GetSequenceToken(),
66 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
54 #if defined(OS_ANDROID) 67 #if defined(OS_ANDROID)
55 return new GCMProfileService(Profile::FromBrowserContext(context)); 68 return new GCMProfileService(profile->GetPath(), blocking_task_runner);
56 #else 69 #else
57 return new GCMProfileService( 70 return new GCMProfileService(
58 Profile::FromBrowserContext(context), 71 profile->GetPrefs(), profile->GetPath(), profile->GetRequestContext(),
59 scoped_ptr<GCMClientFactory>(new GCMClientFactory)); 72 chrome::GetChannel(),
73 scoped_ptr<ProfileIdentityProvider>(new ProfileIdentityProvider(
74 SigninManagerFactory::GetForProfile(profile),
75 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
76 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile))),
77 scoped_ptr<GCMClientFactory>(new GCMClientFactory),
78 content::BrowserThread::GetMessageLoopProxyForThread(
79 content::BrowserThread::UI),
80 content::BrowserThread::GetMessageLoopProxyForThread(
81 content::BrowserThread::IO),
82 blocking_task_runner);
60 #endif 83 #endif
61 } 84 }
62 85
63 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse( 86 content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse(
64 content::BrowserContext* context) const { 87 content::BrowserContext* context) const {
65 return chrome::GetBrowserContextOwnInstanceInIncognito(context); 88 return chrome::GetBrowserContextOwnInstanceInIncognito(context);
66 } 89 }
67 90
68 } // namespace gcm 91 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.cc ('k') | chrome/browser/services/gcm/gcm_profile_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698