Chromium Code Reviews| Index: chrome/browser/signin/profile_oauth2_token_service_factory.cc |
| diff --git a/chrome/browser/signin/profile_oauth2_token_service_factory.cc b/chrome/browser/signin/profile_oauth2_token_service_factory.cc |
| index c8baf9eb598cf63fa61020bf92d29f7b3c5fd866..945b58ee3d73e1b34e5a94c7c87c4712c25507d7 100644 |
| --- a/chrome/browser/signin/profile_oauth2_token_service_factory.cc |
| +++ b/chrome/browser/signin/profile_oauth2_token_service_factory.cc |
| @@ -16,6 +16,39 @@ |
| #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h" |
| #endif |
| +class ProfileOAuth2TokenServiceWrapperImpl |
| + : public ProfileOAuth2TokenServiceWrapper { |
| + public: |
| + explicit ProfileOAuth2TokenServiceWrapperImpl(Profile* profile); |
| + virtual ~ProfileOAuth2TokenServiceWrapperImpl(); |
| + |
| + 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.
|
| + |
| + // BrowserContextKeyedService: |
| + virtual void Shutdown() OVERRIDE; |
| + |
| + private: |
| + scoped_ptr<ProfileOAuth2TokenService> profile_oauth2_token_service_; |
| +}; |
| + |
| +ProfileOAuth2TokenServiceWrapperImpl::ProfileOAuth2TokenServiceWrapperImpl( |
| + Profile* profile) { |
| + profile_oauth2_token_service_.reset(new ProfileOAuth2TokenServiceFactory:: |
| + PlatformSpecificOAuth2TokenService()); |
| + profile_oauth2_token_service_->Initialize(profile); |
| +} |
| + |
| +ProfileOAuth2TokenServiceWrapperImpl::~ProfileOAuth2TokenServiceWrapperImpl() {} |
| + |
| +void ProfileOAuth2TokenServiceWrapperImpl::Shutdown() { |
| + profile_oauth2_token_service_->Shutdown(); |
| +} |
| + |
| +ProfileOAuth2TokenService* |
| +ProfileOAuth2TokenServiceWrapperImpl::GetProfileOAuth2TokenService() { |
| + return profile_oauth2_token_service_.get(); |
| +} |
| + |
| ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() |
| : BrowserContextKeyedServiceFactory( |
| "ProfileOAuth2TokenService", |
| @@ -29,16 +62,25 @@ ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() { |
| ProfileOAuth2TokenService* |
| ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) { |
| - return static_cast<ProfileOAuth2TokenService*>( |
| - GetInstance()->GetServiceForBrowserContext(profile, true)); |
| + ProfileOAuth2TokenServiceWrapper* wrapper = |
| + static_cast<ProfileOAuth2TokenServiceWrapper*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| + if (!wrapper) |
| + return NULL; |
| + return wrapper->GetProfileOAuth2TokenService(); |
| } |
| // static |
| ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService* |
| ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
| Profile* profile) { |
| + ProfileOAuth2TokenServiceWrapper* wrapper = |
| + static_cast<ProfileOAuth2TokenServiceWrapper*>( |
| + GetInstance()->GetServiceForBrowserContext(profile, true)); |
| + if (!wrapper) |
| + return NULL; |
| return static_cast<PlatformSpecificOAuth2TokenService*>( |
| - GetForProfile(profile)); |
| + 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
|
| } |
| // static |
| @@ -51,8 +93,5 @@ BrowserContextKeyedService* |
| ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor( |
| content::BrowserContext* context) const { |
| Profile* profile = static_cast<Profile*>(context); |
| - PlatformSpecificOAuth2TokenService* service = |
| - new PlatformSpecificOAuth2TokenService(); |
| - service->Initialize(profile); |
| - return service; |
| + return new ProfileOAuth2TokenServiceWrapperImpl(profile); |
| } |