diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 17:23:34 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 17:23:34 +0000 |
commit | 671f6db78908d493c1aabc3b8c3be6f4598fed73 (patch) | |
tree | 664675bc106e43398f96cbaefc2aace93353453f | |
parent | 8a585cbb238840eadf792f120d1b80a321b37220 (diff) | |
download | chromium_src-671f6db78908d493c1aabc3b8c3be6f4598fed73.zip chromium_src-671f6db78908d493c1aabc3b8c3be6f4598fed73.tar.gz chromium_src-671f6db78908d493c1aabc3b8c3be6f4598fed73.tar.bz2 |
Eliminate ProfileOAuth2TokenServiceWrapper.
ProfileOAuth2TokenService can now directly be a KeyedService that is shared by
iOS, so the wrapper is no longer needed. The two functions for building a
FakeProfileOAuth2TokenService for a given BrowserContext are placed in a new
fake_profile_oauth2_token_service_builder.* file, since
fake_profile_oauth2_token_service will be componentized but those functions
will not be.
BUG=350709
TBR=thakis
Review URL: https://codereview.chromium.org/201123002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258616 0039d316-1c4b-4281-b951-d872f2087c98
29 files changed, 123 insertions, 199 deletions
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc index 8885d3f..ec66838 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos_unittest.cc @@ -20,7 +20,7 @@ #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -95,7 +95,7 @@ class UserCloudPolicyManagerChromeOSTest : public testing::Test { TestingProfile::TestingFactories factories; factories.push_back( std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build)); + BuildFakeProfileOAuth2TokenService)); profile_ = profile_manager_->CreateTestingProfile( chrome::kInitialProfile, scoped_ptr<PrefServiceSyncable>(), base::UTF8ToUTF16("testing_profile"), 0, std::string(), factories); diff --git a/chrome/browser/extensions/api/identity/account_tracker_unittest.cc b/chrome/browser/extensions/api/identity/account_tracker_unittest.cc index e63b3d3..6f63e94 100644 --- a/chrome/browser/extensions/api/identity/account_tracker_unittest.cc +++ b/chrome/browser/extensions/api/identity/account_tracker_unittest.cc @@ -9,7 +9,7 @@ #include "base/strings/stringprintf.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager_base.h" @@ -272,7 +272,7 @@ class IdentityAccountTrackerTest : public testing::Test { virtual void SetUp() OVERRIDE { TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); builder.AddTestingFactory(SigninManagerFactory::GetInstance(), FakeSigninManagerBase::Build); diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc b/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc index 76f7926..cd00678 100644 --- a/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc +++ b/chrome/browser/invalidation/gcm_invalidation_bridge_unittest.cc @@ -7,7 +7,7 @@ #include "chrome/browser/services/gcm/gcm_profile_service.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/test/base/testing_profile.h" #include "components/signin/core/profile_oauth2_token_service.h" @@ -51,9 +51,8 @@ class GCMInvalidationBridgeTest : public ::testing::Test { virtual void SetUp() OVERRIDE { TestingProfile::Builder builder; - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - &FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + &BuildAutoIssuingFakeProfileOAuth2TokenService); builder.AddTestingFactory(gcm::GCMProfileServiceFactory::GetInstance(), &FakeGCMProfileService::Build); profile_ = builder.Build(); diff --git a/chrome/browser/managed_mode/managed_user_service_unittest.cc b/chrome/browser/managed_mode/managed_user_service_unittest.cc index 81d97c0..f133ed6 100644 --- a/chrome/browser/managed_mode/managed_user_service_unittest.cc +++ b/chrome/browser/managed_mode/managed_user_service_unittest.cc @@ -15,7 +15,7 @@ #include "chrome/browser/managed_mode/managed_user_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/common/chrome_paths.h" @@ -75,7 +75,7 @@ class ManagedUserServiceTest : public ::testing::Test { virtual void SetUp() OVERRIDE { TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); profile_ = builder.Build(); managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile_.get()); diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc index 2585b59..b5bc75d 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc +++ b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc @@ -15,7 +15,7 @@ #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" @@ -176,7 +176,7 @@ class UserPolicySigninServiceTest : public testing::Test { builder.AddTestingFactory(SigninManagerFactory::GetInstance(), SigninManagerFake::Build); builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); profile_ = builder.Build().Pass(); url_factory_.set_remove_fetcher_on_delete(true); diff --git a/chrome/browser/signin/account_reconcilor_unittest.cc b/chrome/browser/signin/account_reconcilor_unittest.cc index c524ef4..1408ea4 100644 --- a/chrome/browser/signin/account_reconcilor_unittest.cc +++ b/chrome/browser/signin/account_reconcilor_unittest.cc @@ -8,7 +8,7 @@ #include "chrome/browser/signin/account_reconcilor.h" #include "chrome/browser/signin/account_reconcilor_factory.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" @@ -104,7 +104,7 @@ AccountReconcilorTest::AccountReconcilorTest() void AccountReconcilorTest::SetUp() { TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); builder.AddTestingFactory(SigninManagerFactory::GetInstance(), FakeSigninManagerBase::Build); builder.AddTestingFactory(AccountReconcilorFactory::GetInstance(), diff --git a/chrome/browser/signin/android_profile_oauth2_token_service.h b/chrome/browser/signin/android_profile_oauth2_token_service.h index 98b0533..9c8d567 100644 --- a/chrome/browser/signin/android_profile_oauth2_token_service.h +++ b/chrome/browser/signin/android_profile_oauth2_token_service.h @@ -68,7 +68,7 @@ class AndroidProfileOAuth2TokenService : public ProfileOAuth2TokenService { virtual void FireRefreshTokensLoadedFromJava(JNIEnv* env, jobject obj); protected: - friend class ProfileOAuth2TokenServiceWrapperImpl; + friend class ProfileOAuth2TokenServiceFactory; AndroidProfileOAuth2TokenService(); virtual ~AndroidProfileOAuth2TokenService(); diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc new file mode 100644 index 0000000..8d54b31 --- /dev/null +++ b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc @@ -0,0 +1,28 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/signin/chrome_signin_client_factory.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" + +// TODO(blundell): Should these be namespaced? +KeyedService* BuildFakeProfileOAuth2TokenService( + content::BrowserContext* context) { + Profile* profile = Profile::FromBrowserContext(context); + FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService(); + service->Initialize( + ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)); + return service; +} + +KeyedService* BuildAutoIssuingFakeProfileOAuth2TokenService( + content::BrowserContext* context) { + Profile* profile = Profile::FromBrowserContext(context); + FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService(); + service->set_auto_post_fetch_response_on_message_loop(true); + service->Initialize( + ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)); + return service; +} diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h new file mode 100644 index 0000000..21672b6 --- /dev/null +++ b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.h @@ -0,0 +1,27 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_BUILDER_H_ +#define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_BUILDER_H_ + +class KeyedService; + +namespace content { +class BrowserContext; +} + +// Helper function to be used with +// BrowserContextKeyedServiceFactory::SetTestingFactory() that returns a +// FakeProfileOAuth2TokenService object. +KeyedService* BuildFakeProfileOAuth2TokenService( + content::BrowserContext* context); + +// Helper function to be used with +// BrowserContextKeyedServiceFactory::SetTestingFactory() that creates a +// FakeProfileOAuth2TokenService object that posts fetch responses on the +// current message loop. +KeyedService* BuildAutoIssuingFakeProfileOAuth2TokenService( + content::BrowserContext* context); + +#endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_BUILDER_H_ diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.cc b/chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.cc deleted file mode 100644 index 500d207..0000000 --- a/chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/signin/chrome_signin_client_factory.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" - -// static -KeyedService* FakeProfileOAuth2TokenServiceWrapper::Build( - content::BrowserContext* context) { - Profile* profile = static_cast<Profile*>(context); - return new FakeProfileOAuth2TokenServiceWrapper(profile, false); -} - -// static -KeyedService* -FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService( - content::BrowserContext* context) { - Profile* profile = static_cast<Profile*>(context); - return new FakeProfileOAuth2TokenServiceWrapper(profile, true); -} - -FakeProfileOAuth2TokenServiceWrapper::FakeProfileOAuth2TokenServiceWrapper( - Profile* profile, - bool auto_issue_tokens) { - if (auto_issue_tokens) - service_.set_auto_post_fetch_response_on_message_loop(true); - service_.Initialize( - ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)); -} - -FakeProfileOAuth2TokenServiceWrapper::~FakeProfileOAuth2TokenServiceWrapper() { - service_.Shutdown(); -} - -ProfileOAuth2TokenService* -FakeProfileOAuth2TokenServiceWrapper::GetProfileOAuth2TokenService() { - return &service_; -} diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h b/chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h deleted file mode 100644 index 17fc7bf..0000000 --- a/chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_WRAPPER_H_ -#define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_WRAPPER_H_ - -#include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" - -class Profile; - -// A wrapper around FakeProfileOAuth2TokenService to be able to use it as a -// BCKS. -class FakeProfileOAuth2TokenServiceWrapper - : public ProfileOAuth2TokenServiceWrapper { - public: - // Helper function to be used with - // KeyedService::SetTestingFactory(). - static KeyedService* Build(content::BrowserContext* context); - - // Helper function to be used with - // KeyedService::SetTestingFactory() that creates a - // FakeProfileOAuth2TokenService object that posts fetch responses on the - // current message loop. - static KeyedService* BuildAutoIssuingTokenService( - content::BrowserContext* context); - - FakeProfileOAuth2TokenServiceWrapper(Profile* profile, - bool auto_issue_tokens); - virtual ~FakeProfileOAuth2TokenServiceWrapper(); - - // ProfileOAuth2TokenServiceWrapper implementation: - virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() OVERRIDE; - - private: - FakeProfileOAuth2TokenService service_; -}; - -#endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_WRAPPER_H_ diff --git a/chrome/browser/signin/profile_oauth2_token_service_factory.cc b/chrome/browser/signin/profile_oauth2_token_service_factory.cc index a7cb8bf..de63065 100644 --- a/chrome/browser/signin/profile_oauth2_token_service_factory.cc +++ b/chrome/browser/signin/profile_oauth2_token_service_factory.cc @@ -17,42 +17,6 @@ #include "components/signin/core/mutable_profile_oauth2_token_service.h" #endif -class ProfileOAuth2TokenServiceWrapperImpl - : public ProfileOAuth2TokenServiceWrapper { - public: - explicit ProfileOAuth2TokenServiceWrapperImpl(Profile* profile); - virtual ~ProfileOAuth2TokenServiceWrapperImpl(); - - // ProfileOAuth2TokenServiceWrapper: - virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() OVERRIDE; - - // KeyedService: - virtual void Shutdown() OVERRIDE; - - private: - scoped_ptr<ProfileOAuth2TokenService> profile_oauth2_token_service_; -}; - -ProfileOAuth2TokenServiceWrapperImpl::ProfileOAuth2TokenServiceWrapperImpl( - Profile* profile) { - profile_oauth2_token_service_.reset(new ProfileOAuth2TokenServiceFactory:: - PlatformSpecificOAuth2TokenService()); - ChromeSigninClient* client = - ChromeSigninClientFactory::GetInstance()->GetForProfile(profile); - profile_oauth2_token_service_->Initialize(client); -} - -ProfileOAuth2TokenServiceWrapperImpl::~ProfileOAuth2TokenServiceWrapperImpl() {} - -void ProfileOAuth2TokenServiceWrapperImpl::Shutdown() { - profile_oauth2_token_service_->Shutdown(); -} - -ProfileOAuth2TokenService* -ProfileOAuth2TokenServiceWrapperImpl::GetProfileOAuth2TokenService() { - return profile_oauth2_token_service_.get(); -} - ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() : BrowserContextKeyedServiceFactory( "ProfileOAuth2TokenService", @@ -65,24 +29,18 @@ ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() { } -// static ProfileOAuth2TokenService* ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) { - ProfileOAuth2TokenServiceWrapper* wrapper = - static_cast<ProfileOAuth2TokenServiceWrapper*>( - GetInstance()->GetServiceForBrowserContext(profile, true)); - if (!wrapper) - return NULL; - return wrapper->GetProfileOAuth2TokenService(); + return static_cast<ProfileOAuth2TokenService*>( + GetInstance()->GetServiceForBrowserContext(profile, true)); } // static ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService* ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( Profile* profile) { - ProfileOAuth2TokenService* service = - ProfileOAuth2TokenServiceFactory::GetForProfile(profile); - return static_cast<PlatformSpecificOAuth2TokenService*>(service); + return static_cast<PlatformSpecificOAuth2TokenService*>( + GetForProfile(profile)); } // static @@ -94,5 +52,9 @@ ProfileOAuth2TokenServiceFactory* KeyedService* ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { Profile* profile = static_cast<Profile*>(context); - return new ProfileOAuth2TokenServiceWrapperImpl(profile); + PlatformSpecificOAuth2TokenService* service = + new PlatformSpecificOAuth2TokenService(); + service->Initialize( + ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)); + return service; } diff --git a/chrome/browser/signin/profile_oauth2_token_service_factory.h b/chrome/browser/signin/profile_oauth2_token_service_factory.h index c58626c..b0a1c28 100644 --- a/chrome/browser/signin/profile_oauth2_token_service_factory.h +++ b/chrome/browser/signin/profile_oauth2_token_service_factory.h @@ -17,13 +17,7 @@ class AndroidProfileOAuth2TokenService; class MutableProfileOAuth2TokenService; #endif -// A wrapper of ProfileOAuth2TokenService so we can use it as a BCKS. -class ProfileOAuth2TokenServiceWrapper : public KeyedService { - public: - virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() = 0; -}; - -/// Singleton that owns all ProfileOAuth2TokenServices and associates them with +// Singleton that owns all ProfileOAuth2TokenServices and associates them with // Profiles. Listens for the Profile's destruction notification and cleans up // the associated ProfileOAuth2TokenService. class ProfileOAuth2TokenServiceFactory @@ -52,7 +46,6 @@ class ProfileOAuth2TokenServiceFactory private: friend struct DefaultSingletonTraits<ProfileOAuth2TokenServiceFactory>; - friend class ProfileOAuth2TokenServiceWrapperImpl; #if defined(OS_ANDROID) typedef AndroidProfileOAuth2TokenService PlatformSpecificOAuth2TokenService; diff --git a/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc b/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc index e2e2c44..0ada8e8 100644 --- a/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc +++ b/chrome/browser/signin/profile_oauth2_token_service_request_unittest.cc @@ -8,7 +8,7 @@ #include <vector> #include "base/threading/thread.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread.h" @@ -84,7 +84,7 @@ void ProfileOAuth2TokenServiceRequestTest::SetUp() { &ui_loop_)); TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - &FakeProfileOAuth2TokenServiceWrapper::Build); + &BuildFakeProfileOAuth2TokenService); profile_ = builder.Build(); oauth2_service_ = (FakeProfileOAuth2TokenService*) diff --git a/chrome/browser/signin/signin_global_error_unittest.cc b/chrome/browser/signin/signin_global_error_unittest.cc index 62e8863..d73152d 100644 --- a/chrome/browser/signin/signin_global_error_unittest.cc +++ b/chrome/browser/signin/signin_global_error_unittest.cc @@ -8,7 +8,7 @@ #include "base/prefs/pref_service.h" #include "chrome/browser/signin/fake_auth_status_provider.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_global_error_factory.h" @@ -30,7 +30,7 @@ class SigninGlobalErrorTest : public testing::Test { // Create a signed-in profile. TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); builder.AddTestingFactory(SigninManagerFactory::GetInstance(), FakeSigninManagerBase::Build); profile_ = builder.Build(); diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/signin/signin_manager_unittest.cc index 0b9bed7..250fda6 100644 --- a/chrome/browser/signin/signin_manager_unittest.cc +++ b/chrome/browser/signin/signin_manager_unittest.cc @@ -18,7 +18,7 @@ #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/common/pref_names.h" @@ -97,7 +97,7 @@ class SigninManagerTest : public testing::Test { prefs_.get()); TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); profile_ = builder.Build(); } diff --git a/chrome/browser/signin/signin_tracker_unittest.cc b/chrome/browser/signin/signin_tracker_unittest.cc index 9df79b4..8557b20 100644 --- a/chrome/browser/signin/signin_tracker_unittest.cc +++ b/chrome/browser/signin/signin_tracker_unittest.cc @@ -11,7 +11,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/fake_auth_status_provider.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" @@ -53,7 +53,7 @@ class SigninTrackerTest : public testing::Test { virtual void SetUp() OVERRIDE { TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); profile_ = builder.Build(); diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc index 4aae06b..e249b7c 100644 --- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc @@ -22,7 +22,7 @@ #include "base/time/time.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -491,9 +491,8 @@ class ProfileSyncServiceAutofillTest virtual void SetUp() OVERRIDE { AbstractProfileSyncServiceTest::SetUp(); TestingProfile::Builder builder; - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + BuildAutoIssuingFakeProfileOAuth2TokenService); profile_ = builder.Build().Pass(); web_database_.reset(new WebDatabaseFake(&autofill_table_)); MockWebDataServiceWrapper* wrapper = diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc index d7eafb5..575c4e0 100644 --- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc @@ -19,7 +19,7 @@ #include "chrome/browser/invalidation/invalidation_service_factory.h" #include "chrome/browser/prefs/pref_model_associator.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -127,9 +127,8 @@ class ProfileSyncServicePreferenceTest virtual void SetUp() { AbstractProfileSyncServiceTest::SetUp(); TestingProfile::Builder builder; - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + BuildAutoIssuingFakeProfileOAuth2TokenService); profile_ = builder.Build().Pass(); invalidation::InvalidationServiceFactory::GetInstance()->SetTestingFactory( profile_.get(), invalidation::FakeInvalidationService::Build); diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc index f78a5cc..b89b1c8 100644 --- a/chrome/browser/sync/profile_sync_service_session_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc @@ -21,7 +21,7 @@ #include "chrome/browser/invalidation/invalidation_service_factory.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -137,9 +137,8 @@ class ProfileSyncServiceSessionTest protected: virtual TestingProfile* CreateProfile() OVERRIDE { TestingProfile::Builder builder; - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + BuildAutoIssuingFakeProfileOAuth2TokenService); // Don't want the profile to create a real ProfileSyncService. builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(), NULL); scoped_ptr<TestingProfile> profile(builder.Build()); diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index 58c2f4b..c0f91dc 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc @@ -8,7 +8,7 @@ #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" @@ -78,9 +78,8 @@ class ProfileSyncServiceStartupTest : public testing::Test { TestingProfile::Builder builder; builder.AddTestingFactory(SigninManagerFactory::GetInstance(), FakeSigninManagerBase::Build); - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + BuildAutoIssuingFakeProfileOAuth2TokenService); builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(), BuildService); return builder.Build(); diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc index babf34c..ee820e9 100644 --- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc @@ -25,7 +25,7 @@ #include "chrome/browser/invalidation/fake_invalidation_service.h" #include "chrome/browser/invalidation/invalidation_service_factory.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -187,9 +187,8 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest { virtual void SetUp() { AbstractProfileSyncServiceTest::SetUp(); TestingProfile::Builder builder; - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + BuildAutoIssuingFakeProfileOAuth2TokenService); profile_ = builder.Build().Pass(); invalidation::InvalidationServiceFactory::GetInstance()->SetTestingFactory( profile_.get(), invalidation::FakeInvalidationService::Build); diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc index e07f250..c0341ab 100644 --- a/chrome/browser/sync/profile_sync_service_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_unittest.cc @@ -11,7 +11,7 @@ #include "chrome/browser/invalidation/invalidation_service_factory.h" #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -96,9 +96,8 @@ class ProfileSyncServiceTest : public ::testing::Test { virtual void SetUp() OVERRIDE { TestingProfile::Builder builder; - builder.AddTestingFactory( - ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::BuildAutoIssuingTokenService); + builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), + BuildAutoIssuingFakeProfileOAuth2TokenService); invalidation::InvalidationServiceFactory::GetInstance()-> RegisterTestingFactory(invalidation::FakeInvalidationService::Build); diff --git a/chrome/browser/sync/startup_controller_unittest.cc b/chrome/browser/sync/startup_controller_unittest.cc index 5c0a4ef..8e91513 100644 --- a/chrome/browser/sync/startup_controller_unittest.cc +++ b/chrome/browser/sync/startup_controller_unittest.cc @@ -11,7 +11,7 @@ #include "chrome/browser/defaults.h" #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_profile.h" @@ -57,9 +57,8 @@ class StartupControllerTest : public testing::Test { virtual void SetUp() OVERRIDE { profile_.reset(new TestingProfile()); sync_prefs_.reset(new sync_driver::SyncPrefs(profile_->GetPrefs())); - token_service_.reset( - static_cast<FakeProfileOAuth2TokenServiceWrapper*>( - FakeProfileOAuth2TokenServiceWrapper::Build(profile_.get()))); + token_service_.reset(static_cast<FakeProfileOAuth2TokenService*>( + BuildFakeProfileOAuth2TokenService(profile_.get()))); signin_.reset(new FakeManagedUserSigninManagerWrapper()); ProfileSyncServiceStartBehavior behavior = @@ -77,6 +76,7 @@ class StartupControllerTest : public testing::Test { virtual void TearDown() OVERRIDE { controller_.reset(); signin_.reset(); + token_service_->Shutdown(); token_service_.reset(); sync_prefs_.reset(); started_ = false; @@ -91,8 +91,7 @@ class StartupControllerTest : public testing::Test { StartupController* controller() { return controller_.get(); } FakeManagedUserSigninManagerWrapper* signin() { return signin_.get(); } FakeProfileOAuth2TokenService* token_service() { - return static_cast<FakeProfileOAuth2TokenService*>( - token_service_->GetProfileOAuth2TokenService()); + return token_service_.get(); } sync_driver::SyncPrefs* sync_prefs() { return sync_prefs_.get(); } Profile* profile() { return profile_.get(); } @@ -102,7 +101,7 @@ class StartupControllerTest : public testing::Test { base::MessageLoop message_loop_; scoped_ptr<StartupController> controller_; scoped_ptr<FakeManagedUserSigninManagerWrapper> signin_; - scoped_ptr<FakeProfileOAuth2TokenServiceWrapper> token_service_; + scoped_ptr<FakeProfileOAuth2TokenService> token_service_; scoped_ptr<sync_driver::SyncPrefs> sync_prefs_; scoped_ptr<TestingProfile> profile_; }; diff --git a/chrome/browser/ui/cocoa/browser/profile_chooser_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/profile_chooser_controller_unittest.mm index 89617b7..48e00c2 100644 --- a/chrome/browser/ui/cocoa/browser/profile_chooser_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser/profile_chooser_controller_unittest.mm @@ -12,7 +12,7 @@ #include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" @@ -36,7 +36,7 @@ class ProfileChooserControllerTest : public CocoaProfileTest { TestingProfile::TestingFactories factories; factories.push_back( std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build)); + BuildFakeProfileOAuth2TokenService)); testing_profile_manager()-> CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), base::ASCIIToUTF16("Test 1"), 0, std::string(), diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc index 8848f84..373015f 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc @@ -15,7 +15,7 @@ #include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" -#include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" +#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" #include "chrome/browser/signin/fake_signin_manager.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" @@ -328,7 +328,7 @@ void OneClickSigninHelperTest::SubmitGAIAPassword( content::BrowserContext* OneClickSigninHelperTest::CreateBrowserContext() { TestingProfile::Builder builder; builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), - FakeProfileOAuth2TokenServiceWrapper::Build); + BuildFakeProfileOAuth2TokenService); scoped_ptr<TestingProfile> profile = builder.Build(); fake_oauth2_token_service_ = diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 025cbe1..df17324 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -173,8 +173,8 @@ 'browser/sessions/session_service_test_helper.h', 'browser/signin/fake_profile_oauth2_token_service.cc', 'browser/signin/fake_profile_oauth2_token_service.h', - 'browser/signin/fake_profile_oauth2_token_service_wrapper.cc', - 'browser/signin/fake_profile_oauth2_token_service_wrapper.h', + 'browser/signin/fake_profile_oauth2_token_service_builder.cc', + 'browser/signin/fake_profile_oauth2_token_service_builder.h', 'browser/signin/fake_signin_manager.cc', 'browser/signin/fake_signin_manager.h', 'browser/ssl/ssl_client_auth_requestor_mock.cc', diff --git a/components/signin/core/mutable_profile_oauth2_token_service.h b/components/signin/core/mutable_profile_oauth2_token_service.h index b9ebc6e..9222dfc 100644 --- a/components/signin/core/mutable_profile_oauth2_token_service.h +++ b/components/signin/core/mutable_profile_oauth2_token_service.h @@ -67,7 +67,7 @@ class MutableProfileOAuth2TokenService : public ProfileOAuth2TokenService, // to information about the account. typedef std::map<std::string, linked_ptr<AccountInfo> > AccountInfoMap; - friend class ProfileOAuth2TokenServiceWrapperImpl; + friend class ProfileOAuth2TokenServiceFactory; MutableProfileOAuth2TokenService(); virtual ~MutableProfileOAuth2TokenService(); diff --git a/components/signin/core/profile_oauth2_token_service.h b/components/signin/core/profile_oauth2_token_service.h index b4ede3a..526c3cd 100644 --- a/components/signin/core/profile_oauth2_token_service.h +++ b/components/signin/core/profile_oauth2_token_service.h @@ -20,7 +20,7 @@ class URLRequestContextGetter; class GoogleServiceAuthError; class SigninClient; -// ProfileOAuth2TokenService is a class that retrieves +// ProfileOAuth2TokenService is a KeyedService that retrieves // OAuth2 access tokens for a given set of scopes using the OAuth2 login // refresh tokens. // @@ -34,14 +34,16 @@ class SigninClient; // // Note: requests should be started from the UI thread. To start a // request from other thread, please use ProfileOAuth2TokenServiceRequest. -class ProfileOAuth2TokenService : public OAuth2TokenService { +class ProfileOAuth2TokenService : public OAuth2TokenService, + public KeyedService { public: virtual ~ProfileOAuth2TokenService(); // Initializes this token service with the SigninClient. virtual void Initialize(SigninClient* client); - virtual void Shutdown(); + // KeyedService implementation. + virtual void Shutdown() OVERRIDE; // Lists account IDs of all accounts with a refresh token. virtual std::vector<std::string> GetAccounts() OVERRIDE; |