| Index: components/sync/driver/glue/sync_backend_host_impl.cc
|
| diff --git a/components/sync/driver/glue/sync_backend_host_impl.cc b/components/sync/driver/glue/sync_backend_host_impl.cc
|
| index d8b2d4b332b6d4dd34218430e1d93418c10890d4..119fcb13cd392799dfd95e718e98eaeb61bbc8d7 100644
|
| --- a/components/sync/driver/glue/sync_backend_host_impl.cc
|
| +++ b/components/sync/driver/glue/sync_backend_host_impl.cc
|
| @@ -72,7 +72,7 @@ SyncBackendHostImpl::~SyncBackendHostImpl() {
|
|
|
| void SyncBackendHostImpl::Initialize(
|
| SyncFrontend* frontend,
|
| - base::Thread* sync_thread,
|
| + scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner,
|
| const WeakHandle<JsEventHandler>& event_handler,
|
| const GURL& sync_service_url,
|
| const std::string& sync_user_agent,
|
| @@ -85,8 +85,8 @@ void SyncBackendHostImpl::Initialize(
|
| const base::Closure& report_unrecoverable_error_function,
|
| const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
|
| std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) {
|
| - CHECK(sync_thread);
|
| - sync_thread_ = sync_thread;
|
| + CHECK(sync_task_runner);
|
| + sync_task_runner_ = sync_task_runner;
|
|
|
| registrar_ = base::MakeUnique<SyncBackendRegistrar>(
|
| name_, base::Bind(&SyncClient::CreateModelWorkerForGroup,
|
| @@ -120,7 +120,7 @@ void SyncBackendHostImpl::Initialize(
|
| sync_prefs_->GetInvalidationVersions(&invalidation_versions);
|
|
|
| std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions(
|
| - sync_thread_->message_loop(), registrar_.get(), workers,
|
| + sync_task_runner_, registrar_.get(), workers,
|
| sync_client_->GetExtensionsActivity(), event_handler, sync_service_url,
|
| sync_user_agent, http_post_provider_factory_getter.Run(
|
| core_->GetRequestContextCancelationSignal()),
|
| @@ -138,15 +138,14 @@ void SyncBackendHostImpl::Initialize(
|
|
|
| void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) {
|
| DCHECK(ui_thread_->BelongsToCurrentThread());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types));
|
| }
|
|
|
| void SyncBackendHostImpl::UpdateCredentials(
|
| const SyncCredentials& credentials) {
|
| - DCHECK(sync_thread_->IsRunning());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, core_,
|
| credentials));
|
| }
|
| @@ -157,14 +156,13 @@ void SyncBackendHostImpl::StartSyncingWithServer() {
|
| ModelSafeRoutingInfo routing_info;
|
| registrar_->GetModelSafeRoutingInfo(&routing_info);
|
|
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_,
|
| routing_info, sync_prefs_->GetLastPollTime()));
|
| }
|
|
|
| void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase,
|
| bool is_explicit) {
|
| - DCHECK(sync_thread_->IsRunning());
|
| if (!IsNigoriEnabled()) {
|
| NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori"
|
| " is disabled.";
|
| @@ -183,7 +181,7 @@ void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase,
|
| cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE);
|
|
|
| // Post an encryption task on the syncer thread.
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase,
|
| core_, passphrase, is_explicit));
|
| }
|
| @@ -212,7 +210,7 @@ bool SyncBackendHostImpl::SetDecryptionPassphrase(
|
| return false;
|
|
|
| // Post a decryption task on the syncer thread.
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase,
|
| core_, passphrase));
|
|
|
| @@ -235,8 +233,6 @@ void SyncBackendHostImpl::StopSyncingForShutdown() {
|
| // Immediately stop sending messages to the frontend.
|
| frontend_ = nullptr;
|
|
|
| - DCHECK(sync_thread_->IsRunning());
|
| -
|
| registrar_->RequestWorkerStopOnUIThread();
|
|
|
| core_->ShutdownOnUIThread();
|
| @@ -246,7 +242,6 @@ void SyncBackendHostImpl::Shutdown(ShutdownReason reason) {
|
| // StopSyncingForShutdown() (which nulls out |frontend_|) should be
|
| // called first.
|
| DCHECK(!frontend_);
|
| - DCHECK(sync_thread_->IsRunning());
|
|
|
| if (invalidation_handler_registered_) {
|
| if (reason == DISABLE_SYNC) {
|
| @@ -262,12 +257,12 @@ void SyncBackendHostImpl::Shutdown(ShutdownReason reason) {
|
| // Shut down and destroy SyncManager. SyncManager holds a pointer to
|
| // |registrar_| so its destruction must be sequenced before the destruction of
|
| // |registrar_|.
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason));
|
| core_ = nullptr;
|
|
|
| // Destroy |registrar_|.
|
| - sync_thread_->task_runner()->DeleteSoon(FROM_HERE, registrar_.release());
|
| + sync_task_runner_->DeleteSoon(FROM_HERE, registrar_.release());
|
| }
|
|
|
| void SyncBackendHostImpl::UnregisterInvalidationIds() {
|
| @@ -391,7 +386,7 @@ ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes(
|
| }
|
|
|
| void SyncBackendHostImpl::EnableEncryptEverything() {
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_));
|
| }
|
| @@ -468,12 +463,12 @@ void SyncBackendHostImpl::GetModelSafeRoutingInfo(
|
|
|
| void SyncBackendHostImpl::FlushDirectory() const {
|
| DCHECK(initialized());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_));
|
| }
|
|
|
| void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(
|
| &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding,
|
| @@ -481,14 +476,14 @@ void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
|
| }
|
|
|
| void SyncBackendHostImpl::DisableProtocolEventForwarding() {
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_));
|
| }
|
|
|
| void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() {
|
| DCHECK(initialized());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding,
|
| core_));
|
| @@ -496,7 +491,7 @@ void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() {
|
|
|
| void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() {
|
| DCHECK(initialized());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding,
|
| core_));
|
| @@ -504,7 +499,7 @@ void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() {
|
|
|
| void SyncBackendHostImpl::InitCore(
|
| std::unique_ptr<DoInitializeOptions> options) {
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_,
|
| base::Passed(&options)));
|
| }
|
| @@ -524,7 +519,7 @@ void SyncBackendHostImpl::RequestConfigureSyncer(
|
| config_types.to_purge = to_purge;
|
| config_types.to_journal = to_journal;
|
| config_types.to_unapply = to_unapply;
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason,
|
| config_types, routing_info, ready_task, retry_callback));
|
| @@ -650,14 +645,14 @@ void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop(
|
| }
|
|
|
| void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) {
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange,
|
| core_, state));
|
| }
|
|
|
| void SyncBackendHostImpl::OnIncomingInvalidation(
|
| const ObjectIdInvalidationMap& invalidation_map) {
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation,
|
| core_, invalidation_map));
|
| }
|
| @@ -786,7 +781,7 @@ void SyncBackendHostImpl::UpdateInvalidationVersions(
|
| void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) {
|
| DCHECK(ui_thread_->BelongsToCurrentThread());
|
|
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types));
|
| }
|
| @@ -794,7 +789,7 @@ void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) {
|
| void SyncBackendHostImpl::ClearServerData(
|
| const SyncManager::ClearServerDataCallback& callback) {
|
| DCHECK(ui_thread_->BelongsToCurrentThread());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&SyncBackendHostCore::DoClearServerData, core_, callback));
|
| }
|
| @@ -802,7 +797,7 @@ void SyncBackendHostImpl::ClearServerData(
|
| void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch,
|
| bool empty_jar) {
|
| DCHECK(ui_thread_->BelongsToCurrentThread());
|
| - sync_thread_->task_runner()->PostTask(
|
| + sync_task_runner_->PostTask(
|
| FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, core_,
|
| account_mismatch, empty_jar));
|
| }
|
|
|