Commit d005448e authored by rogerta@chromium.org's avatar rogerta@chromium.org

This is the third CL of several that will eventually replace TokenService with

ProfileOAuth2TokenService. In this CL, the dependencies on TS are removed
from profile sync service.

BUG=305247

Review URL: https://codereview.chromium.org/60733019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235870 0039d316-1c4b-4281-b951-d872f2087c98
parent 907f3921
...@@ -320,7 +320,8 @@ bool TiclInvalidationService::IsReadyToStart() { ...@@ -320,7 +320,8 @@ bool TiclInvalidationService::IsReadyToStart() {
if (!oauth2_token_service_) { if (!oauth2_token_service_) {
DVLOG(2) DVLOG(2)
<< "Not starting TiclInvalidationService: TokenService unavailable."; << "Not starting TiclInvalidationService: "
<< "OAuth2TokenService unavailable.";
return false; return false;
} }
......
...@@ -89,7 +89,7 @@ class GaiaOAuthFetcher : public net::URLFetcherDelegate { ...@@ -89,7 +89,7 @@ class GaiaOAuthFetcher : public net::URLFetcherDelegate {
// //
// service_scope will be used as a service name. For example, Chromium Sync // service_scope will be used as a service name. For example, Chromium Sync
// uses https://www.googleapis.com/auth/chromesync for its OAuth2 service // uses https://www.googleapis.com/auth/chromesync for its OAuth2 service
// scope here as well as for its service name in TokenService. // scope.
virtual void StartOAuthWrapBridge( virtual void StartOAuthWrapBridge(
const std::string& oauth1_access_token, const std::string& oauth1_access_token,
const std::string& oauth1_access_token_secret, const std::string& oauth1_access_token_secret,
......
...@@ -45,7 +45,6 @@ AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest() ...@@ -45,7 +45,6 @@ AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest()
: thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD |
content::TestBrowserThreadBundle::REAL_FILE_THREAD | content::TestBrowserThreadBundle::REAL_FILE_THREAD |
content::TestBrowserThreadBundle::REAL_IO_THREAD), content::TestBrowserThreadBundle::REAL_IO_THREAD),
token_service_(NULL),
sync_service_(NULL) { sync_service_(NULL) {
} }
...@@ -67,12 +66,6 @@ bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) { ...@@ -67,12 +66,6 @@ bool AbstractProfileSyncServiceTest::CreateRoot(ModelType model_type) {
sync_service_->GetUserShare()); sync_service_->GetUserShare());
} }
// static
BrowserContextKeyedService* AbstractProfileSyncServiceTest::BuildTokenService(
content::BrowserContext* profile) {
return new TokenService;
}
CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test, CreateRootHelper::CreateRootHelper(AbstractProfileSyncServiceTest* test,
ModelType model_type) ModelType model_type)
: callback_(base::Bind(&CreateRootHelper::CreateRootCallback, : callback_(base::Bind(&CreateRootHelper::CreateRootCallback,
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h" #include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "sync/internal_api/public/base/model_type.h" #include "sync/internal_api/public/base/model_type.h"
...@@ -48,12 +47,8 @@ class AbstractProfileSyncServiceTest : public testing::Test { ...@@ -48,12 +47,8 @@ class AbstractProfileSyncServiceTest : public testing::Test {
bool CreateRoot(syncer::ModelType model_type); bool CreateRoot(syncer::ModelType model_type);
static BrowserContextKeyedService* BuildTokenService(
content::BrowserContext* profile);
protected: protected:
content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserThreadBundle thread_bundle_;
TokenService* token_service_;
TestProfileSyncService* sync_service_; TestProfileSyncService* sync_service_;
}; };
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/backend_migrator.h" #include "chrome/browser/sync/backend_migrator.h"
#include "chrome/browser/sync/glue/change_processor.h" #include "chrome/browser/sync/glue/change_processor.h"
#include "chrome/browser/sync/glue/chrome_encryptor.h" #include "chrome/browser/sync/glue/chrome_encryptor.h"
...@@ -280,19 +278,12 @@ void ProfileSyncService::TrySyncDatatypePrefRecovery() { ...@@ -280,19 +278,12 @@ void ProfileSyncService::TrySyncDatatypePrefRecovery() {
void ProfileSyncService::TryStart() { void ProfileSyncService::TryStart() {
if (!IsSyncEnabledAndLoggedIn()) if (!IsSyncEnabledAndLoggedIn())
return; return;
TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
if (!token_service) // Don't start sync until tokens are loaded, because the user can be
return; // "signed in" long before the tokens get loaded, and we don't want to
// Don't start the backend if the token service hasn't finished loading tokens // generate spurious auth errors.
// yet. Note if the backend is started before the sync token has been loaded, if (!IsOAuthRefreshTokenAvailable())
// GetCredentials() will return bogus credentials. On auto_start platforms
// (like ChromeOS) we don't start sync until tokens are loaded, because the
// user can be "signed in" on those platforms long before the tokens get
// loaded, and we don't want to generate spurious auth errors.
if (!IsOAuthRefreshTokenAvailable() &&
!(!auto_start_enabled_ && token_service->TokensLoadedFromDB())) {
return; return;
}
// If we got here then tokens are loaded and user logged in and sync is // If we got here then tokens are loaded and user logged in and sync is
// enabled. If OAuth refresh token is not available then something is wrong. // enabled. If OAuth refresh token is not available then something is wrong.
...@@ -731,7 +722,7 @@ void ProfileSyncService::OnRefreshTokenRevoked( ...@@ -731,7 +722,7 @@ void ProfileSyncService::OnRefreshTokenRevoked(
access_token_.clear(); access_token_.clear();
// The additional check around IsOAuthRefreshTokenAvailable() above // The additional check around IsOAuthRefreshTokenAvailable() above
// prevents us sounding the alarm if we actually have a valid token but // prevents us sounding the alarm if we actually have a valid token but
// a refresh attempt by TokenService failed for any variety of reasons // a refresh attempt failed for any variety of reasons
// (e.g. flaky network). It's possible the token we do have is also // (e.g. flaky network). It's possible the token we do have is also
// invalid, but in that case we should already have (or can expect) an // invalid, but in that case we should already have (or can expect) an
// auth error sent from the sync backend. // auth error sent from the sync backend.
...@@ -741,7 +732,7 @@ void ProfileSyncService::OnRefreshTokenRevoked( ...@@ -741,7 +732,7 @@ void ProfileSyncService::OnRefreshTokenRevoked(
} }
void ProfileSyncService::OnRefreshTokensLoaded() { void ProfileSyncService::OnRefreshTokensLoaded() {
// This notification gets fired when TokenService loads the tokens // This notification gets fired when OAuth2TokenService loads the tokens
// from storage. // from storage.
// Initialize the backend if sync is enabled. If the sync token was // Initialize the backend if sync is enabled. If the sync token was
// not loaded, GetCredentials() will generate invalid credentials to // not loaded, GetCredentials() will generate invalid credentials to
......
...@@ -690,7 +690,7 @@ class ProfileSyncService : public ProfileSyncServiceBase, ...@@ -690,7 +690,7 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// to claim ownership of sync thread from backend. // to claim ownership of sync thread from backend.
void ShutdownImpl(browser_sync::SyncBackendHost::ShutdownOption option); void ShutdownImpl(browser_sync::SyncBackendHost::ShutdownOption option);
// Return SyncCredentials from the TokenService. // Return SyncCredentials from the OAuth2TokenService.
syncer::SyncCredentials GetCredentials(); syncer::SyncCredentials GetCredentials();
virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler();
...@@ -782,7 +782,7 @@ class ProfileSyncService : public ProfileSyncServiceBase, ...@@ -782,7 +782,7 @@ class ProfileSyncService : public ProfileSyncServiceBase,
void ConsumeCachedPassphraseIfPossible(); void ConsumeCachedPassphraseIfPossible();
// RequestAccessToken initiates RPC to request downscoped access token from // RequestAccessToken initiates RPC to request downscoped access token from
// refresh token. This happens when TokenService loads OAuth2 login token and // refresh token. This happens when a new OAuth2 login token is loaded and
// when sync server returns AUTH_ERROR which indicates it is time to refresh // when sync server returns AUTH_ERROR which indicates it is time to refresh
// token. // token.
virtual void RequestAccessToken(); virtual void RequestAccessToken();
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/fake_oauth2_token_service.h" #include "chrome/browser/sync/fake_oauth2_token_service.h"
#include "chrome/browser/sync/glue/autofill_data_type_controller.h" #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
...@@ -202,12 +201,12 @@ class TokenWebDataServiceFake : public TokenWebData { ...@@ -202,12 +201,12 @@ class TokenWebDataServiceFake : public TokenWebData {
virtual WebDataService::Handle GetAllTokens( virtual WebDataService::Handle GetAllTokens(
WebDataServiceConsumer* consumer) OVERRIDE { WebDataServiceConsumer* consumer) OVERRIDE {
// TODO(tim): It would be nice if WebDataService was injected on // TODO(tim): It would be nice if WebDataService was injected on
// construction of TokenService rather than fetched by Initialize so that // construction of ProfileOAuth2TokenService rather than fetched by
// this isn't necessary (we could pass a NULL service). We currently do // Initialize so that this isn't necessary (we could pass a NULL service).
// return it via EXPECT_CALLs, but without depending on order-of- // We currently do return it via EXPECT_CALLs, but without depending on
// initialization (which seems way more fragile) we can't tell which // order-of-initialization (which seems way more fragile) we can't tell
// component is asking at what time, and some components in these Autofill // which component is asking at what time, and some components in these
// tests require a WebDataService. // Autofill tests require a WebDataService.
return 0; return 0;
} }
...@@ -526,9 +525,6 @@ class ProfileSyncServiceAutofillTest ...@@ -526,9 +525,6 @@ class ProfileSyncServiceAutofillTest
personal_data_manager_ = personal_data_manager_ =
personal_data_manager_service->GetPersonalDataManager(); personal_data_manager_service->GetPersonalDataManager();
token_service_ = static_cast<TokenService*>(
TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), BuildTokenService));
EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1); EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1);
EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1); EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1);
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/invalidation/p2p_invalidation_service.h" #include "chrome/browser/invalidation/p2p_invalidation_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/profile_oauth2_token_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_base.h" #include "chrome/browser/signin/signin_manager_base.h"
#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/about_sync_util.h" #include "chrome/browser/sync/about_sync_util.h"
#include "chrome/browser/sync/glue/data_type_controller.h" #include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
#include "sync/internal_api/public/sessions/sync_session_snapshot.h" #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
#include "sync/internal_api/public/util/sync_string_conversions.h" #include "sync/internal_api/public/util/sync_string_conversions.h"
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/managed_mode/managed_user_constants.h"
#endif
using syncer::sessions::SyncSessionSnapshot; using syncer::sessions::SyncSessionSnapshot;
using invalidation::P2PInvalidationService; using invalidation::P2PInvalidationService;
...@@ -209,9 +213,16 @@ bool ProfileSyncServiceHarness::SetupSync( ...@@ -209,9 +213,16 @@ bool ProfileSyncServiceHarness::SetupSync(
chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
content::Source<Profile>(profile_), content::Source<Profile>(profile_),
content::Details<const GoogleServiceSigninSuccessDetails>(&details)); content::Details<const GoogleServiceSigninSuccessDetails>(&details));
TokenServiceFactory::GetForProfile(profile_)->IssueAuthTokenForTest(
GaiaConstants::kGaiaOAuth2LoginRefreshToken, #if defined(ENABLE_MANAGED_USERS)
GenerateFakeOAuth2RefreshTokenString()); std::string account_id = profile_->IsManaged() ?
managed_users::kManagedUserPseudoEmail : username_;
#else
std::string account_id = username_;
#endif
DCHECK(!account_id.empty());
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
UpdateCredentials(account_id, GenerateFakeOAuth2RefreshTokenString());
// Wait for the OnBackendInitialized() callback. // Wait for the OnBackendInitialized() callback.
if (!AwaitBackendInitialized()) { if (!AwaitBackendInitialized()) {
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/fake_oauth2_token_service.h" #include "chrome/browser/sync/fake_oauth2_token_service.h"
#include "chrome/browser/sync/glue/password_change_processor.h" #include "chrome/browser/sync/glue/password_change_processor.h"
...@@ -197,9 +196,6 @@ class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest { ...@@ -197,9 +196,6 @@ class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest {
SigninManagerBase* signin = SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(profile_.get()); SigninManagerFactory::GetForProfile(profile_.get());
signin->SetAuthenticatedUsername("test_user@gmail.com"); signin->SetAuthenticatedUsername("test_user@gmail.com");
token_service_ = static_cast<TokenService*>(
TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), BuildTokenService));
PasswordTestProfileSyncService* sync = PasswordTestProfileSyncService* sync =
static_cast<PasswordTestProfileSyncService*>( static_cast<PasswordTestProfileSyncService*>(
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "chrome/browser/prefs/pref_model_associator.h" #include "chrome/browser/prefs/pref_model_associator.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/fake_oauth2_token_service.h" #include "chrome/browser/sync/fake_oauth2_token_service.h"
#include "chrome/browser/sync/glue/generic_change_processor.h" #include "chrome/browser/sync/glue/generic_change_processor.h"
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/fake_oauth2_token_service.h" #include "chrome/browser/sync/fake_oauth2_token_service.h"
#include "chrome/browser/sync/glue/device_info.h" #include "chrome/browser/sync/glue/device_info.h"
......
...@@ -58,25 +58,6 @@ ACTION_P2(InvokeOnConfigureDone, pss, result) { ...@@ -58,25 +58,6 @@ ACTION_P2(InvokeOnConfigureDone, pss, result) {
service->OnConfigureDone(configure_result); service->OnConfigureDone(configure_result);
} }
class FakeTokenService : public TokenService {
public:
FakeTokenService() {}
virtual ~FakeTokenService() {}
virtual void LoadTokensFromDB() OVERRIDE {
set_tokens_loaded(true);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_TOKEN_LOADING_FINISHED,
content::Source<TokenService>(this),
content::NotificationService::NoDetails());
}
static BrowserContextKeyedService* BuildFakeTokenService(
content::BrowserContext* profile) {
return new FakeTokenService();
}
};
class ProfileSyncServiceStartupTest : public testing::Test { class ProfileSyncServiceStartupTest : public testing::Test {
public: public:
ProfileSyncServiceStartupTest() ProfileSyncServiceStartupTest()
...@@ -104,9 +85,7 @@ class ProfileSyncServiceStartupTest : public testing::Test { ...@@ -104,9 +85,7 @@ class ProfileSyncServiceStartupTest : public testing::Test {
builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
FakeOAuth2TokenService::BuildTokenService); FakeOAuth2TokenService::BuildTokenService);
builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(), builder.AddTestingFactory(ProfileSyncServiceFactory::GetInstance(),
ProfileSyncServiceStartupTest::BuildService); BuildService);
builder.AddTestingFactory(TokenServiceFactory::GetInstance(),
FakeTokenService::BuildFakeTokenService);
return builder.Build(); return builder.Build();
} }
...@@ -250,8 +229,6 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) { ...@@ -250,8 +229,6 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) {
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
SigninManagerFactory::GetForProfile( SigninManagerFactory::GetForProfile(
profile_.get())->Initialize(profile_.get(), NULL); profile_.get())->Initialize(profile_.get(), NULL);
TokenService* token_service = static_cast<TokenService*>(
TokenServiceFactory::GetForProfile(profile_.get()));
CreateSyncService(); CreateSyncService();
// Should not actually start, rather just clean things up and wait // Should not actually start, rather just clean things up and wait
...@@ -277,12 +254,13 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) { ...@@ -277,12 +254,13 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartNoCredentials) {
chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
content::Source<Profile>(profile_.get()), content::Source<Profile>(profile_.get()),
content::Details<const GoogleServiceSigninSuccessDetails>(&details)); content::Details<const GoogleServiceSigninSuccessDetails>(&details));
// NOTE: Unlike StartFirstTime, this test does not issue any auth tokens. ProfileOAuth2TokenService* token_service =
token_service->LoadTokensFromDB(); ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
token_service->LoadCredentials();
sync_->SetSetupInProgress(false); sync_->SetSetupInProgress(false);
// ProfileSyncService should try to start by requesting access token. // ProfileSyncService should try to start by requesting access token.
// This request should fail as login token was not issued to TokenService. // This request should fail as login token was not issued.
EXPECT_FALSE(sync_->ShouldPushChanges()); EXPECT_FALSE(sync_->ShouldPushChanges());
EXPECT_EQ(GoogleServiceAuthError::USER_NOT_SIGNED_UP, EXPECT_EQ(GoogleServiceAuthError::USER_NOT_SIGNED_UP,
sync_->GetAuthError().state()); sync_->GetAuthError().state());
...@@ -303,9 +281,6 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartInvalidCredentials) { ...@@ -303,9 +281,6 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartInvalidCredentials) {
DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); DataTypeManagerMock* data_type_manager = SetUpDataTypeManager();
EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0); EXPECT_CALL(*data_type_manager, Configure(_, _)).Times(0);
// Issue login token so that ProfileSyncServer tries to initialize backend.
TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
sync_->Initialize(); sync_->Initialize();
...@@ -328,8 +303,6 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartInvalidCredentials) { ...@@ -328,8 +303,6 @@ TEST_F(ProfileSyncServiceStartupTest, DISABLED_StartInvalidCredentials) {
content::Source<Profile>(profile_.get()), content::Source<Profile>(profile_.get()),
content::Details<const GoogleServiceSigninSuccessDetails>(&details)); content::Details<const GoogleServiceSigninSuccessDetails>(&details));
TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
sync_->SetSetupInProgress(false); sync_->SetSetupInProgress(false);
// Verify we successfully finish startup and configuration. // Verify we successfully finish startup and configuration.
...@@ -343,13 +316,13 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { ...@@ -343,13 +316,13 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) {
CreateSyncBackendHost(_, _, _)).Times(0); CreateSyncBackendHost(_, _, _)).Times(0);
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
TokenService* token_service = static_cast<TokenService*>( ProfileOAuth2TokenService* token_service =
TokenServiceFactory::GetForProfile(profile_.get())); ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get());
sync_->Initialize(); sync_->Initialize();
// Sync should not start because there are no tokens yet. // Sync should not start because there are no tokens yet.
EXPECT_FALSE(sync_->ShouldPushChanges()); EXPECT_FALSE(sync_->ShouldPushChanges());
token_service->LoadTokensFromDB(); token_service->LoadCredentials();
sync_->SetSetupInProgress(false); sync_->SetSetupInProgress(false);
// Sync should not start because there are still no tokens. // Sync should not start because there are still no tokens.
...@@ -469,8 +442,6 @@ TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) { ...@@ -469,8 +442,6 @@ TEST_F(ProfileSyncServiceStartupTest, ManagedStartup) {
CreateDataTypeManager(_, _, _, _, _, _)).Times(0); CreateDataTypeManager(_, _, _, _, _, _)).Times(0);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
sync_->Initialize(); sync_->Initialize();
} }
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "chrome/browser/invalidation/invalidation_service_factory.h" #include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h" #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/fake_oauth2_token_service.h" #include "chrome/browser/sync/fake_oauth2_token_service.h"
#include "chrome/browser/sync/glue/data_type_error_handler_mock.h" #include "chrome/browser/sync/glue/data_type_error_handler_mock.h"
...@@ -214,9 +213,6 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest { ...@@ -214,9 +213,6 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
SigninManagerBase* signin = SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(profile_.get()); SigninManagerFactory::GetForProfile(profile_.get());
signin->SetAuthenticatedUsername("test"); signin->SetAuthenticatedUsername("test");
token_service_ = static_cast<TokenService*>(
TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), BuildTokenService));
sync_service_ = static_cast<TestProfileSyncService*>( sync_service_ = static_cast<TestProfileSyncService*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), profile_.get(),
......
...@@ -106,6 +106,7 @@ class TestProfileSyncService : public ProfileSyncService { ...@@ -106,6 +106,7 @@ class TestProfileSyncService : public ProfileSyncService {
public: public:
// TODO(tim): Remove |synchronous_backend_initialization|, and add ability to // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to
// inject TokenService alongside SigninManager. // inject TokenService alongside SigninManager.
// TODO(rogerta): what does above comment mean?
TestProfileSyncService( TestProfileSyncService(
ProfileSyncComponentsFactory* factory, ProfileSyncComponentsFactory* factory,
Profile* profile, Profile* profile,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment