Chromium Code Reviews| Index: chrome/browser/sync/test_profile_sync_service.cc |
| diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc |
| index 06d586a0400341f005d316d14909c04bd2e29d2d..d33d7f08690d2a7f878f158c7e9bfee8e5e1b46b 100644 |
| --- a/chrome/browser/sync/test_profile_sync_service.cc |
| +++ b/chrome/browser/sync/test_profile_sync_service.cc |
| @@ -85,7 +85,7 @@ void SyncBackendHostForProfileSyncTest::InitCore( |
| new TestInternalComponentsFactory(factory_switches, storage); |
| SyncBackendHost::InitCore(test_options); |
| - if (synchronous_init_) { |
| + if (synchronous_init_ && !base::MessageLoop::current()->is_running()) { |
| // The SyncBackend posts a task to the current loop when |
| // initialization completes. |
| base::MessageLoop::current()->Run(); |
| @@ -247,6 +247,23 @@ TestProfileSyncService::components_factory_mock() { |
| return static_cast<ProfileSyncComponentsFactoryMock*>(factory()); |
| } |
| +void TestProfileSyncService::RequestAccessToken() { |
| + ProfileSyncService::RequestAccessToken(); |
| + if (synchronous_backend_initialization_) { |
| + base::MessageLoop::current()->Run(); |
| + } |
| +} |
| + |
| +void TestProfileSyncService::OnGetTokenFailure( |
| + const OAuth2TokenService::Request* request, |
| + const GoogleServiceAuthError& error) { |
| + ProfileSyncService::OnGetTokenFailure(request, error); |
| + if (synchronous_backend_initialization_) { |
| + base::MessageLoop::current()->Quit(); |
|
Andrew T Wilson (Slow)
2013/06/04 14:37:32
Should we also add an OnGetTokenSuccess() loop tha
pavely
2013/06/04 20:11:13
In success case TryStart will be called and will r
|
| + } |
| +} |
| + |
| + |
| void TestProfileSyncService::OnBackendInitialized( |
| const syncer::WeakHandle<syncer::JsBackend>& backend, |
| const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| @@ -299,3 +316,23 @@ void TestProfileSyncService::CreateBackend() { |
| fail_initial_download_, |
| storage_option_)); |
| } |
| + |
| +scoped_ptr<OAuth2TokenService::Request> FakeOAuth2TokenService::StartRequest( |
| + const OAuth2TokenService::ScopeSet& scopes, |
| + OAuth2TokenService::Consumer* consumer) { |
| + // Ensure token in question is cached and never expires. Request will succeed |
| + // without network IO. |
| + RegisterCacheEntry(GetRefreshToken(), scopes, "access_token", |
| + base::Time::Max()); |
| + return ProfileOAuth2TokenService::StartRequest(scopes, consumer); |
| +} |
| + |
| +BrowserContextKeyedService* FakeOAuth2TokenService::BuildTokenService( |
| + content::BrowserContext* context) { |
| + Profile* profile = static_cast<Profile*>(context); |
| + |
| + FakeOAuth2TokenService* service = |
| + new FakeOAuth2TokenService(context->GetRequestContext()); |
| + service->Initialize(profile); |
| + return service; |
| +} |