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

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: Response to review 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 // ProfileOAuth2TokenServiceWrapper:
26 virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() OVERRIDE;
27
28 // BrowserContextKeyedService:
29 virtual void Shutdown() OVERRIDE;
30
31 private:
32 scoped_ptr<ProfileOAuth2TokenService> profile_oauth2_token_service_;
33 };
34
35 ProfileOAuth2TokenServiceWrapperImpl::ProfileOAuth2TokenServiceWrapperImpl(
36 Profile* profile) {
37 profile_oauth2_token_service_.reset(new ProfileOAuth2TokenServiceFactory::
38 PlatformSpecificOAuth2TokenService());
39 profile_oauth2_token_service_->Initialize(profile);
40 }
41
42 ProfileOAuth2TokenServiceWrapperImpl::~ProfileOAuth2TokenServiceWrapperImpl() {}
43
44 void ProfileOAuth2TokenServiceWrapperImpl::Shutdown() {
45 profile_oauth2_token_service_->Shutdown();
46 }
47
48 ProfileOAuth2TokenService*
49 ProfileOAuth2TokenServiceWrapperImpl::GetProfileOAuth2TokenService() {
50 return profile_oauth2_token_service_.get();
51 }
52
19 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() 53 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory()
20 : BrowserContextKeyedServiceFactory( 54 : BrowserContextKeyedServiceFactory(
21 "ProfileOAuth2TokenService", 55 "ProfileOAuth2TokenService",
22 BrowserContextDependencyManager::GetInstance()) { 56 BrowserContextDependencyManager::GetInstance()) {
23 DependsOn(GlobalErrorServiceFactory::GetInstance()); 57 DependsOn(GlobalErrorServiceFactory::GetInstance());
24 DependsOn(WebDataServiceFactory::GetInstance()); 58 DependsOn(WebDataServiceFactory::GetInstance());
25 } 59 }
26 60
27 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() { 61 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() {
28 } 62 }
29 63
64 // static
30 ProfileOAuth2TokenService* 65 ProfileOAuth2TokenService*
31 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) { 66 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) {
32 return static_cast<ProfileOAuth2TokenService*>( 67 ProfileOAuth2TokenServiceWrapper* wrapper =
33 GetInstance()->GetServiceForBrowserContext(profile, true)); 68 static_cast<ProfileOAuth2TokenServiceWrapper*>(
69 GetInstance()->GetServiceForBrowserContext(profile, true));
70 if (!wrapper)
71 return NULL;
72 return wrapper->GetProfileOAuth2TokenService();
34 } 73 }
35 74
36 // static 75 // static
37 ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService* 76 ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService*
38 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 77 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
39 Profile* profile) { 78 Profile* profile) {
40 return static_cast<PlatformSpecificOAuth2TokenService*>( 79 ProfileOAuth2TokenService* service =
41 GetForProfile(profile)); 80 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
81 return static_cast<PlatformSpecificOAuth2TokenService*>(service);
42 } 82 }
43 83
44 // static 84 // static
45 ProfileOAuth2TokenServiceFactory* 85 ProfileOAuth2TokenServiceFactory*
46 ProfileOAuth2TokenServiceFactory::GetInstance() { 86 ProfileOAuth2TokenServiceFactory::GetInstance() {
47 return Singleton<ProfileOAuth2TokenServiceFactory>::get(); 87 return Singleton<ProfileOAuth2TokenServiceFactory>::get();
48 } 88 }
49 89
50 BrowserContextKeyedService* 90 BrowserContextKeyedService*
51 ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor( 91 ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor(
52 content::BrowserContext* context) const { 92 content::BrowserContext* context) const {
53 Profile* profile = static_cast<Profile*>(context); 93 Profile* profile = static_cast<Profile*>(context);
54 PlatformSpecificOAuth2TokenService* service = 94 return new ProfileOAuth2TokenServiceWrapperImpl(profile);
55 new PlatformSpecificOAuth2TokenService();
56 service->Initialize(profile);
57 return service;
58 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698