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

Side by Side Diff: chrome/browser/signin/profile_oauth2_token_service_factory.cc

Issue 148513010: Eliminate ProfileOAuth2TokenService being a BCKS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/signin/profile_oauth2_token_service_factory.h" 5 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/signin/profile_oauth2_token_service.h" 8 #include "chrome/browser/signin/profile_oauth2_token_service.h"
9 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 9 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
10 #include "chrome/browser/webdata/web_data_service_factory.h" 10 #include "chrome/browser/webdata/web_data_service_factory.h"
11 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 11 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
12 12
13 #if defined(OS_ANDROID) 13 #if defined(OS_ANDROID)
14 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" 14 #include "chrome/browser/signin/android_profile_oauth2_token_service.h"
15 #else 15 #else
16 #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h" 16 #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h"
17 #endif 17 #endif
18 18
19 class ProfileOAuth2TokenServiceWrapperImpl
20 : public ProfileOAuth2TokenServiceWrapper {
21 public:
22 explicit ProfileOAuth2TokenServiceWrapperImpl(Profile* profile);
23 virtual ~ProfileOAuth2TokenServiceWrapperImpl();
24
25 virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() OVERRIDE;
Roger Tawa OOO till Jul 10th 2014/02/10 19:49:13 Nit: // ProfileOAuth2TokenServiceWrapper implement
blundell 2014/02/13 16:07:06 Done.
26
27 // BrowserContextKeyedService:
28 virtual void Shutdown() OVERRIDE;
29
30 private:
31 scoped_ptr<ProfileOAuth2TokenService> profile_oauth2_token_service_;
32 };
33
34 ProfileOAuth2TokenServiceWrapperImpl::ProfileOAuth2TokenServiceWrapperImpl(
35 Profile* profile) {
36 profile_oauth2_token_service_.reset(new ProfileOAuth2TokenServiceFactory::
37 PlatformSpecificOAuth2TokenService());
38 profile_oauth2_token_service_->Initialize(profile);
39 }
40
41 ProfileOAuth2TokenServiceWrapperImpl::~ProfileOAuth2TokenServiceWrapperImpl() {}
42
43 void ProfileOAuth2TokenServiceWrapperImpl::Shutdown() {
44 profile_oauth2_token_service_->Shutdown();
45 }
46
47 ProfileOAuth2TokenService*
48 ProfileOAuth2TokenServiceWrapperImpl::GetProfileOAuth2TokenService() {
49 return profile_oauth2_token_service_.get();
50 }
51
19 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() 52 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory()
20 : BrowserContextKeyedServiceFactory( 53 : BrowserContextKeyedServiceFactory(
21 "ProfileOAuth2TokenService", 54 "ProfileOAuth2TokenService",
22 BrowserContextDependencyManager::GetInstance()) { 55 BrowserContextDependencyManager::GetInstance()) {
23 DependsOn(GlobalErrorServiceFactory::GetInstance()); 56 DependsOn(GlobalErrorServiceFactory::GetInstance());
24 DependsOn(WebDataServiceFactory::GetInstance()); 57 DependsOn(WebDataServiceFactory::GetInstance());
25 } 58 }
26 59
27 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() { 60 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() {
28 } 61 }
29 62
30 ProfileOAuth2TokenService* 63 ProfileOAuth2TokenService*
31 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) { 64 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) {
32 return static_cast<ProfileOAuth2TokenService*>( 65 ProfileOAuth2TokenServiceWrapper* wrapper =
33 GetInstance()->GetServiceForBrowserContext(profile, true)); 66 static_cast<ProfileOAuth2TokenServiceWrapper*>(
67 GetInstance()->GetServiceForBrowserContext(profile, true));
68 if (!wrapper)
69 return NULL;
70 return wrapper->GetProfileOAuth2TokenService();
34 } 71 }
35 72
36 // static 73 // static
37 ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService* 74 ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService*
38 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 75 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
39 Profile* profile) { 76 Profile* profile) {
77 ProfileOAuth2TokenServiceWrapper* wrapper =
78 static_cast<ProfileOAuth2TokenServiceWrapper*>(
79 GetInstance()->GetServiceForBrowserContext(profile, true));
80 if (!wrapper)
81 return NULL;
40 return static_cast<PlatformSpecificOAuth2TokenService*>( 82 return static_cast<PlatformSpecificOAuth2TokenService*>(
41 GetForProfile(profile)); 83 wrapper->GetProfileOAuth2TokenService());
Roger Tawa OOO till Jul 10th 2014/02/10 19:49:13 Why can't this call GetForProfile() ?
blundell 2014/02/13 16:07:06 Great idea, done. On 2014/02/10 19:49:13, Roger T
42 } 84 }
43 85
44 // static 86 // static
45 ProfileOAuth2TokenServiceFactory* 87 ProfileOAuth2TokenServiceFactory*
46 ProfileOAuth2TokenServiceFactory::GetInstance() { 88 ProfileOAuth2TokenServiceFactory::GetInstance() {
47 return Singleton<ProfileOAuth2TokenServiceFactory>::get(); 89 return Singleton<ProfileOAuth2TokenServiceFactory>::get();
48 } 90 }
49 91
50 BrowserContextKeyedService* 92 BrowserContextKeyedService*
51 ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor( 93 ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor(
52 content::BrowserContext* context) const { 94 content::BrowserContext* context) const {
53 Profile* profile = static_cast<Profile*>(context); 95 Profile* profile = static_cast<Profile*>(context);
54 PlatformSpecificOAuth2TokenService* service = 96 return new ProfileOAuth2TokenServiceWrapperImpl(profile);
55 new PlatformSpecificOAuth2TokenService();
56 service->Initialize(profile);
57 return service;
58 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698