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 3f2becec6f74797b37d3849281f087aef1ff7eae..d739ded11f6d87faeea8b96e9f55dafac4690345 100644 |
--- a/chrome/browser/sync/test_profile_sync_service.cc |
+++ b/chrome/browser/sync/test_profile_sync_service.cc |
@@ -5,19 +5,21 @@ |
#include "chrome/browser/sync/test_profile_sync_service.h" |
#include "chrome/browser/chrome_notification_types.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" |
#include "chrome/browser/sync/glue/sync_backend_host.h" |
#include "chrome/browser/sync/glue/sync_backend_host_core.h" |
#include "chrome/browser/sync/profile_sync_components_factory.h" |
+#include "chrome/browser/sync/profile_sync_components_factory_mock.h" |
#include "chrome/browser/sync/test/test_http_bridge_factory.h" |
#include "sync/internal_api/public/test/sync_manager_factory_for_profile_sync_test.h" |
+#include "sync/internal_api/public/test/test_internal_components_factory.h" |
#include "sync/internal_api/public/user_share.h" |
#include "sync/js/js_reply_handler.h" |
#include "sync/protocol/encryption.pb.h" |
using syncer::InternalComponentsFactory; |
-using syncer::ModelSafeRoutingInfo; |
using syncer::TestInternalComponentsFactory; |
using syncer::UserShare; |
@@ -26,42 +28,23 @@ namespace browser_sync { |
SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
Profile* profile, |
const base::WeakPtr<SyncPrefs>& sync_prefs, |
- base::Closure& callback, |
- bool set_initial_sync_ended_on_init, |
- bool synchronous_init, |
- bool fail_initial_download, |
- syncer::StorageOption storage_option) |
+ base::Closure& callback) |
: browser_sync::SyncBackendHostImpl( |
profile->GetDebugName(), profile, sync_prefs), |
- callback_(callback), |
- fail_initial_download_(fail_initial_download), |
- set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), |
- synchronous_init_(synchronous_init), |
- storage_option_(storage_option), |
- weak_ptr_factory_(this) {} |
+ callback_(callback) {} |
SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
-namespace { |
- |
-scoped_ptr<syncer::HttpPostProviderFactory> MakeTestHttpBridgeFactory() { |
- return scoped_ptr<syncer::HttpPostProviderFactory>( |
- new browser_sync::TestHttpBridgeFactory()); |
-} |
- |
-} // namespace |
- |
void SyncBackendHostForProfileSyncTest::InitCore( |
scoped_ptr<DoInitializeOptions> options) { |
- options->http_bridge_factory = MakeTestHttpBridgeFactory(); |
+ options->http_bridge_factory = |
+ scoped_ptr<syncer::HttpPostProviderFactory>( |
+ new browser_sync::TestHttpBridgeFactory()); |
options->sync_manager_factory.reset( |
- new syncer::SyncManagerFactoryForProfileSyncTest( |
- callback_, |
- set_initial_sync_ended_on_init_)); |
+ new syncer::SyncManagerFactoryForProfileSyncTest(callback_)); |
options->credentials.email = "testuser@gmail.com"; |
options->credentials.sync_token = "token"; |
options->restored_key_for_bootstrapping = ""; |
- syncer::StorageOption storage = storage_option_; |
// It'd be nice if we avoided creating the InternalComponentsFactory in the |
// first place, but SyncBackendHost will have created one by now so we must |
@@ -69,23 +52,10 @@ void SyncBackendHostForProfileSyncTest::InitCore( |
InternalComponentsFactory::Switches factory_switches = |
options->internal_components_factory->GetSwitches(); |
options->internal_components_factory.reset( |
- new TestInternalComponentsFactory(factory_switches, storage)); |
+ new TestInternalComponentsFactory(factory_switches, |
+ syncer::STORAGE_IN_MEMORY)); |
SyncBackendHostImpl::InitCore(options.Pass()); |
- if (synchronous_init_ && !base::MessageLoop::current()->is_running()) { |
- // The SyncBackend posts a task to the current loop when |
- // initialization completes. |
- base::MessageLoop::current()->Run(); |
- } |
-} |
- |
-void SyncBackendHostForProfileSyncTest::UpdateCredentials( |
- const syncer::SyncCredentials& credentials) { |
- // If we had failed the initial download, complete initialization now. |
- if (!initial_download_closure_.is_null()) { |
- initial_download_closure_.Run(); |
- initial_download_closure_.Reset(); |
- } |
} |
void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
@@ -100,8 +70,6 @@ void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
syncer::ModelTypeSet)>& ready_task, |
const base::Closure& retry_callback) { |
syncer::ModelTypeSet failed_configuration_types; |
- if (fail_initial_download_) |
- failed_configuration_types = to_download; |
// The first parameter there should be the set of enabled types. That's not |
// something we have access to from this strange test harness. We'll just |
@@ -114,41 +82,12 @@ void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
ready_task); |
} |
-void |
-SyncBackendHostForProfileSyncTest::HandleInitializationSuccessOnFrontendLoop( |
- const syncer::WeakHandle<syncer::JsBackend> js_backend, |
- const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> |
- debug_info_listener) { |
- if (fail_initial_download_) { |
- // We interrupt this successful init to bring you a simulated failure. |
- initial_download_closure_ = base::Bind( |
- &SyncBackendHostForProfileSyncTest:: |
- HandleInitializationSuccessOnFrontendLoop, |
- weak_ptr_factory_.GetWeakPtr(), |
- js_backend, |
- debug_info_listener); |
- HandleControlTypesDownloadRetry(); |
- if (synchronous_init_) |
- base::MessageLoop::current()->Quit(); |
- } else { |
- SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( |
- js_backend, |
- debug_info_listener); |
- } |
-} |
- |
} // namespace browser_sync |
syncer::TestIdFactory* TestProfileSyncService::id_factory() { |
return &id_factory_; |
} |
-browser_sync::SyncBackendHostForProfileSyncTest* |
- TestProfileSyncService::GetBackendForTest() { |
- return static_cast<browser_sync::SyncBackendHostForProfileSyncTest*>( |
- ProfileSyncService::GetBackendForTest()); |
-} |
- |
syncer::WeakHandle<syncer::JsEventHandler> |
TestProfileSyncService::GetJsEventHandler() { |
return syncer::WeakHandle<syncer::JsEventHandler>(); |
@@ -159,19 +98,12 @@ TestProfileSyncService::TestProfileSyncService( |
Profile* profile, |
SigninManagerBase* signin, |
ProfileOAuth2TokenService* oauth2_token_service, |
- ProfileSyncService::StartBehavior behavior, |
- bool synchronous_backend_initialization) |
+ ProfileSyncService::StartBehavior behavior) |
: ProfileSyncService(factory, |
profile, |
signin, |
oauth2_token_service, |
- behavior), |
- synchronous_backend_initialization_( |
- synchronous_backend_initialization), |
- synchronous_sync_configuration_(false), |
- set_initial_sync_ended_on_init_(true), |
- fail_initial_download_(false), |
- storage_option_(syncer::STORAGE_IN_MEMORY) { |
+ behavior) { |
SetSyncSetupCompleted(); |
} |
@@ -192,8 +124,7 @@ BrowserContextKeyedService* TestProfileSyncService::BuildAutoStartAsyncInit( |
profile, |
signin, |
oauth2_token_service, |
- ProfileSyncService::AUTO_START, |
- false); |
+ ProfileSyncService::AUTO_START); |
} |
ProfileSyncComponentsFactoryMock* |
@@ -202,82 +133,20 @@ TestProfileSyncService::components_factory_mock() { |
return static_cast<ProfileSyncComponentsFactoryMock*>(factory()); |
} |
-void TestProfileSyncService::RequestAccessToken() { |
- ProfileSyncService::RequestAccessToken(); |
- if (synchronous_backend_initialization_) { |
- base::MessageLoop::current()->Run(); |
- } |
-} |
- |
-void TestProfileSyncService::OnGetTokenSuccess( |
- const OAuth2TokenService::Request* request, |
- const std::string& access_token, |
- const base::Time& expiration_time) { |
- ProfileSyncService::OnGetTokenSuccess(request, access_token, |
- expiration_time); |
- if (synchronous_backend_initialization_) { |
- base::MessageLoop::current()->Quit(); |
- } |
-} |
- |
-void TestProfileSyncService::OnGetTokenFailure( |
- const OAuth2TokenService::Request* request, |
- const GoogleServiceAuthError& error) { |
- ProfileSyncService::OnGetTokenFailure(request, error); |
- if (synchronous_backend_initialization_) { |
- base::MessageLoop::current()->Quit(); |
- } |
-} |
- |
- |
-void TestProfileSyncService::OnBackendInitialized( |
- const syncer::WeakHandle<syncer::JsBackend>& backend, |
- const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
- debug_info_listener, |
- bool success) { |
- ProfileSyncService::OnBackendInitialized(backend, |
- debug_info_listener, |
- success); |
- |
- // TODO(akalin): Figure out a better way to do this. |
- if (synchronous_backend_initialization_) { |
- base::MessageLoop::current()->Quit(); |
- } |
-} |
- |
void TestProfileSyncService::OnConfigureDone( |
const browser_sync::DataTypeManager::ConfigureResult& result) { |
ProfileSyncService::OnConfigureDone(result); |
- if (!synchronous_sync_configuration_) |
- base::MessageLoop::current()->Quit(); |
+ base::MessageLoop::current()->Quit(); |
} |
UserShare* TestProfileSyncService::GetUserShare() const { |
return backend_->GetUserShare(); |
} |
-void TestProfileSyncService::dont_set_initial_sync_ended_on_init() { |
- set_initial_sync_ended_on_init_ = false; |
-} |
-void TestProfileSyncService::set_synchronous_sync_configuration() { |
- synchronous_sync_configuration_ = true; |
-} |
-void TestProfileSyncService::fail_initial_download() { |
- fail_initial_download_ = true; |
-} |
-void TestProfileSyncService::set_storage_option( |
- syncer::StorageOption storage_option) { |
- storage_option_ = storage_option; |
-} |
- |
void TestProfileSyncService::CreateBackend() { |
backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
profile(), |
sync_prefs_.AsWeakPtr(), |
- callback_, |
- set_initial_sync_ended_on_init_, |
- synchronous_backend_initialization_, |
- fail_initial_download_, |
- storage_option_)); |
+ callback_)); |
} |