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 95b6cb59d6baec9b80de37d12ed36ad09ca8d074..7c7f702fc04fd9e961d8852d0502814eed4f20f0 100644 |
--- a/chrome/browser/sync/test_profile_sync_service.cc |
+++ b/chrome/browser/sync/test_profile_sync_service.cc |
@@ -43,11 +43,12 @@ SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
syncer::StorageOption storage_option) |
: browser_sync::SyncBackendHost( |
profile->GetDebugName(), profile, sync_prefs, invalidator_storage), |
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
id_factory_(id_factory), |
callback_(callback), |
+ fail_initial_download_(fail_initial_download), |
set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), |
synchronous_init_(synchronous_init), |
- fail_initial_download_(fail_initial_download), |
storage_option_(storage_option) {} |
SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
@@ -89,6 +90,15 @@ void SyncBackendHostForProfileSyncTest::InitCore( |
} |
} |
+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( |
syncer::ConfigureReason reason, |
syncer::ModelTypeSet types_to_config, |
@@ -104,7 +114,7 @@ void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
} |
void SyncBackendHostForProfileSyncTest |
- ::HandleSyncManagerInitializationOnFrontendLoop( |
+ ::HandleSyncManagerInitializationOnFrontendLoop( |
const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
debug_info_listener, |
@@ -141,8 +151,20 @@ void SyncBackendHostForProfileSyncTest |
restored_types = syncer::ModelTypeSet::All(); |
} |
- SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( |
- js_backend, debug_info_listener, restored_types); |
+ initial_download_closure_ = base::Bind( |
+ &SyncBackendHostForProfileSyncTest::ContinueInitialization, |
+ weak_ptr_factory_.GetWeakPtr(), |
+ js_backend, |
+ debug_info_listener, |
+ restored_types); |
+ if (fail_initial_download_) { |
+ frontend()->OnSyncConfigureRetry(); |
+ if (synchronous_init_) |
+ MessageLoop::current()->Quit(); |
+ } else { |
+ initial_download_closure_.Run(); |
+ initial_download_closure_.Reset(); |
+ } |
} |
void SyncBackendHostForProfileSyncTest::SetInitialSyncEndedForAllTypes() { |
@@ -167,6 +189,15 @@ void SyncBackendHostForProfileSyncTest::EmitOnIncomingInvalidation( |
frontend()->OnIncomingInvalidation(invalidation_map, source); |
} |
+void SyncBackendHostForProfileSyncTest::ContinueInitialization( |
+ const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
+ const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
+ debug_info_listener, |
+ syncer::ModelTypeSet restored_types) { |
+ SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( |
+ js_backend, debug_info_listener, restored_types); |
+} |
+ |
} // namespace browser_sync |
syncer::TestIdFactory* TestProfileSyncService::id_factory() { |