| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/driver/glue/sync_backend_host_impl.h" | 5 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 weak_ptr_factory_.GetWeakPtr()); | 65 weak_ptr_factory_.GetWeakPtr()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 SyncBackendHostImpl::~SyncBackendHostImpl() { | 68 SyncBackendHostImpl::~SyncBackendHostImpl() { |
| 69 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor."; | 69 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor."; |
| 70 DCHECK(!registrar_.get()); | 70 DCHECK(!registrar_.get()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SyncBackendHostImpl::Initialize( | 73 void SyncBackendHostImpl::Initialize( |
| 74 SyncFrontend* frontend, | 74 SyncFrontend* frontend, |
| 75 base::Thread* sync_thread, | 75 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, |
| 76 const WeakHandle<JsEventHandler>& event_handler, | 76 const WeakHandle<JsEventHandler>& event_handler, |
| 77 const GURL& sync_service_url, | 77 const GURL& sync_service_url, |
| 78 const std::string& sync_user_agent, | 78 const std::string& sync_user_agent, |
| 79 const SyncCredentials& credentials, | 79 const SyncCredentials& credentials, |
| 80 bool delete_sync_data_folder, | 80 bool delete_sync_data_folder, |
| 81 bool enable_local_sync_backend, | 81 bool enable_local_sync_backend, |
| 82 const base::FilePath& local_sync_backend_folder, | 82 const base::FilePath& local_sync_backend_folder, |
| 83 std::unique_ptr<SyncManagerFactory> sync_manager_factory, | 83 std::unique_ptr<SyncManagerFactory> sync_manager_factory, |
| 84 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | 84 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
| 85 const base::Closure& report_unrecoverable_error_function, | 85 const base::Closure& report_unrecoverable_error_function, |
| 86 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 86 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 87 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { | 87 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { |
| 88 CHECK(sync_thread); | 88 CHECK(sync_task_runner); |
| 89 sync_thread_ = sync_thread; | 89 sync_task_runner_ = sync_task_runner; |
| 90 | 90 |
| 91 registrar_ = base::MakeUnique<SyncBackendRegistrar>( | 91 registrar_ = base::MakeUnique<SyncBackendRegistrar>( |
| 92 name_, base::Bind(&SyncClient::CreateModelWorkerForGroup, | 92 name_, base::Bind(&SyncClient::CreateModelWorkerForGroup, |
| 93 base::Unretained(sync_client_))); | 93 base::Unretained(sync_client_))); |
| 94 | 94 |
| 95 DCHECK(frontend); | 95 DCHECK(frontend); |
| 96 frontend_ = frontend; | 96 frontend_ = frontend; |
| 97 | 97 |
| 98 std::vector<scoped_refptr<ModelSafeWorker>> workers; | 98 std::vector<scoped_refptr<ModelSafeWorker>> workers; |
| 99 registrar_->GetWorkers(&workers); | 99 registrar_->GetWorkers(&workers); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 113 } | 113 } |
| 114 if (cl->HasSwitch(switches::kSyncShortNudgeDelayForTest)) { | 114 if (cl->HasSwitch(switches::kSyncShortNudgeDelayForTest)) { |
| 115 factory_switches.nudge_delay = | 115 factory_switches.nudge_delay = |
| 116 EngineComponentsFactory::NudgeDelay::SHORT_NUDGE_DELAY; | 116 EngineComponentsFactory::NudgeDelay::SHORT_NUDGE_DELAY; |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::map<ModelType, int64_t> invalidation_versions; | 119 std::map<ModelType, int64_t> invalidation_versions; |
| 120 sync_prefs_->GetInvalidationVersions(&invalidation_versions); | 120 sync_prefs_->GetInvalidationVersions(&invalidation_versions); |
| 121 | 121 |
| 122 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( | 122 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( |
| 123 sync_thread_->message_loop(), registrar_.get(), workers, | 123 sync_task_runner_, registrar_.get(), workers, |
| 124 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, | 124 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, |
| 125 sync_user_agent, http_post_provider_factory_getter.Run( | 125 sync_user_agent, http_post_provider_factory_getter.Run( |
| 126 core_->GetRequestContextCancelationSignal()), | 126 core_->GetRequestContextCancelationSignal()), |
| 127 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", | 127 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", |
| 128 std::move(sync_manager_factory), delete_sync_data_folder, | 128 std::move(sync_manager_factory), delete_sync_data_folder, |
| 129 enable_local_sync_backend, local_sync_backend_folder, | 129 enable_local_sync_backend, local_sync_backend_folder, |
| 130 sync_prefs_->GetEncryptionBootstrapToken(), | 130 sync_prefs_->GetEncryptionBootstrapToken(), |
| 131 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), | 131 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), |
| 132 std::unique_ptr<EngineComponentsFactory>( | 132 std::unique_ptr<EngineComponentsFactory>( |
| 133 new EngineComponentsFactoryImpl(factory_switches)), | 133 new EngineComponentsFactoryImpl(factory_switches)), |
| 134 unrecoverable_error_handler, report_unrecoverable_error_function, | 134 unrecoverable_error_handler, report_unrecoverable_error_function, |
| 135 std::move(saved_nigori_state), invalidation_versions)); | 135 std::move(saved_nigori_state), invalidation_versions)); |
| 136 InitCore(std::move(init_opts)); | 136 InitCore(std::move(init_opts)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { | 139 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { |
| 140 DCHECK(ui_thread_->BelongsToCurrentThread()); | 140 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 141 sync_thread_->task_runner()->PostTask( | 141 sync_task_runner_->PostTask( |
| 142 FROM_HERE, | 142 FROM_HERE, |
| 143 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); | 143 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void SyncBackendHostImpl::UpdateCredentials( | 146 void SyncBackendHostImpl::UpdateCredentials( |
| 147 const SyncCredentials& credentials) { | 147 const SyncCredentials& credentials) { |
| 148 DCHECK(sync_thread_->IsRunning()); | 148 sync_task_runner_->PostTask( |
| 149 sync_thread_->task_runner()->PostTask( | |
| 150 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, core_, | 149 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, core_, |
| 151 credentials)); | 150 credentials)); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void SyncBackendHostImpl::StartSyncingWithServer() { | 153 void SyncBackendHostImpl::StartSyncingWithServer() { |
| 155 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; | 154 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; |
| 156 | 155 |
| 157 ModelSafeRoutingInfo routing_info; | 156 ModelSafeRoutingInfo routing_info; |
| 158 registrar_->GetModelSafeRoutingInfo(&routing_info); | 157 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 159 | 158 |
| 160 sync_thread_->task_runner()->PostTask( | 159 sync_task_runner_->PostTask( |
| 161 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_, | 160 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_, |
| 162 routing_info, sync_prefs_->GetLastPollTime())); | 161 routing_info, sync_prefs_->GetLastPollTime())); |
| 163 } | 162 } |
| 164 | 163 |
| 165 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase, | 164 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase, |
| 166 bool is_explicit) { | 165 bool is_explicit) { |
| 167 DCHECK(sync_thread_->IsRunning()); | |
| 168 if (!IsNigoriEnabled()) { | 166 if (!IsNigoriEnabled()) { |
| 169 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" | 167 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" |
| 170 " is disabled."; | 168 " is disabled."; |
| 171 return; | 169 return; |
| 172 } | 170 } |
| 173 | 171 |
| 174 // We should never be called with an empty passphrase. | 172 // We should never be called with an empty passphrase. |
| 175 DCHECK(!passphrase.empty()); | 173 DCHECK(!passphrase.empty()); |
| 176 | 174 |
| 177 // This should only be called by the frontend. | 175 // This should only be called by the frontend. |
| 178 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 176 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 179 | 177 |
| 180 // SetEncryptionPassphrase should never be called if we are currently | 178 // SetEncryptionPassphrase should never be called if we are currently |
| 181 // encrypted with an explicit passphrase. | 179 // encrypted with an explicit passphrase. |
| 182 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || | 180 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || |
| 183 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); | 181 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); |
| 184 | 182 |
| 185 // Post an encryption task on the syncer thread. | 183 // Post an encryption task on the syncer thread. |
| 186 sync_thread_->task_runner()->PostTask( | 184 sync_task_runner_->PostTask( |
| 187 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, | 185 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, |
| 188 core_, passphrase, is_explicit)); | 186 core_, passphrase, is_explicit)); |
| 189 } | 187 } |
| 190 | 188 |
| 191 bool SyncBackendHostImpl::SetDecryptionPassphrase( | 189 bool SyncBackendHostImpl::SetDecryptionPassphrase( |
| 192 const std::string& passphrase) { | 190 const std::string& passphrase) { |
| 193 if (!IsNigoriEnabled()) { | 191 if (!IsNigoriEnabled()) { |
| 194 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" | 192 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" |
| 195 " is disabled."; | 193 " is disabled."; |
| 196 return false; | 194 return false; |
| 197 } | 195 } |
| 198 | 196 |
| 199 // We should never be called with an empty passphrase. | 197 // We should never be called with an empty passphrase. |
| 200 DCHECK(!passphrase.empty()); | 198 DCHECK(!passphrase.empty()); |
| 201 | 199 |
| 202 // This should only be called by the frontend. | 200 // This should only be called by the frontend. |
| 203 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 201 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 204 | 202 |
| 205 // This should only be called when we have cached pending keys. | 203 // This should only be called when we have cached pending keys. |
| 206 DCHECK(cached_pending_keys_.has_blob()); | 204 DCHECK(cached_pending_keys_.has_blob()); |
| 207 | 205 |
| 208 // Check the passphrase that was provided against our local cache of the | 206 // Check the passphrase that was provided against our local cache of the |
| 209 // cryptographer's pending keys. If this was unsuccessful, the UI layer can | 207 // cryptographer's pending keys. If this was unsuccessful, the UI layer can |
| 210 // immediately call OnPassphraseRequired without showing the user a spinner. | 208 // immediately call OnPassphraseRequired without showing the user a spinner. |
| 211 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) | 209 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) |
| 212 return false; | 210 return false; |
| 213 | 211 |
| 214 // Post a decryption task on the syncer thread. | 212 // Post a decryption task on the syncer thread. |
| 215 sync_thread_->task_runner()->PostTask( | 213 sync_task_runner_->PostTask( |
| 216 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, | 214 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, |
| 217 core_, passphrase)); | 215 core_, passphrase)); |
| 218 | 216 |
| 219 // Since we were able to decrypt the cached pending keys with the passphrase | 217 // Since we were able to decrypt the cached pending keys with the passphrase |
| 220 // provided, we immediately alert the UI layer that the passphrase was | 218 // provided, we immediately alert the UI layer that the passphrase was |
| 221 // accepted. This will avoid the situation where a user enters a passphrase, | 219 // accepted. This will avoid the situation where a user enters a passphrase, |
| 222 // clicks OK, immediately reopens the advanced settings dialog, and gets an | 220 // clicks OK, immediately reopens the advanced settings dialog, and gets an |
| 223 // unnecessary prompt for a passphrase. | 221 // unnecessary prompt for a passphrase. |
| 224 // Note: It is not guaranteed that the passphrase will be accepted by the | 222 // Note: It is not guaranteed that the passphrase will be accepted by the |
| 225 // syncer thread, since we could receive a new nigori node while the task is | 223 // syncer thread, since we could receive a new nigori node while the task is |
| 226 // pending. This scenario is a valid race, and SetDecryptionPassphrase can | 224 // pending. This scenario is a valid race, and SetDecryptionPassphrase can |
| 227 // trigger a new OnPassphraseRequired if it needs to. | 225 // trigger a new OnPassphraseRequired if it needs to. |
| 228 NotifyPassphraseAccepted(); | 226 NotifyPassphraseAccepted(); |
| 229 return true; | 227 return true; |
| 230 } | 228 } |
| 231 | 229 |
| 232 void SyncBackendHostImpl::StopSyncingForShutdown() { | 230 void SyncBackendHostImpl::StopSyncingForShutdown() { |
| 233 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 231 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 234 | 232 |
| 235 // Immediately stop sending messages to the frontend. | 233 // Immediately stop sending messages to the frontend. |
| 236 frontend_ = nullptr; | 234 frontend_ = nullptr; |
| 237 | 235 |
| 238 DCHECK(sync_thread_->IsRunning()); | |
| 239 | |
| 240 registrar_->RequestWorkerStopOnUIThread(); | 236 registrar_->RequestWorkerStopOnUIThread(); |
| 241 | 237 |
| 242 core_->ShutdownOnUIThread(); | 238 core_->ShutdownOnUIThread(); |
| 243 } | 239 } |
| 244 | 240 |
| 245 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) { | 241 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) { |
| 246 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | 242 // StopSyncingForShutdown() (which nulls out |frontend_|) should be |
| 247 // called first. | 243 // called first. |
| 248 DCHECK(!frontend_); | 244 DCHECK(!frontend_); |
| 249 DCHECK(sync_thread_->IsRunning()); | |
| 250 | 245 |
| 251 if (invalidation_handler_registered_) { | 246 if (invalidation_handler_registered_) { |
| 252 if (reason == DISABLE_SYNC) { | 247 if (reason == DISABLE_SYNC) { |
| 253 UnregisterInvalidationIds(); | 248 UnregisterInvalidationIds(); |
| 254 } | 249 } |
| 255 invalidator_->UnregisterInvalidationHandler(this); | 250 invalidator_->UnregisterInvalidationHandler(this); |
| 256 invalidator_ = nullptr; | 251 invalidator_ = nullptr; |
| 257 } | 252 } |
| 258 invalidation_handler_registered_ = false; | 253 invalidation_handler_registered_ = false; |
| 259 | 254 |
| 260 model_type_connector_.reset(); | 255 model_type_connector_.reset(); |
| 261 | 256 |
| 262 // Shut down and destroy SyncManager. SyncManager holds a pointer to | 257 // Shut down and destroy SyncManager. SyncManager holds a pointer to |
| 263 // |registrar_| so its destruction must be sequenced before the destruction of | 258 // |registrar_| so its destruction must be sequenced before the destruction of |
| 264 // |registrar_|. | 259 // |registrar_|. |
| 265 sync_thread_->task_runner()->PostTask( | 260 sync_task_runner_->PostTask( |
| 266 FROM_HERE, base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason)); | 261 FROM_HERE, base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason)); |
| 267 core_ = nullptr; | 262 core_ = nullptr; |
| 268 | 263 |
| 269 // Destroy |registrar_|. | 264 // Destroy |registrar_|. |
| 270 sync_thread_->task_runner()->DeleteSoon(FROM_HERE, registrar_.release()); | 265 sync_task_runner_->DeleteSoon(FROM_HERE, registrar_.release()); |
| 271 } | 266 } |
| 272 | 267 |
| 273 void SyncBackendHostImpl::UnregisterInvalidationIds() { | 268 void SyncBackendHostImpl::UnregisterInvalidationIds() { |
| 274 if (invalidation_handler_registered_) { | 269 if (invalidation_handler_registered_) { |
| 275 CHECK(invalidator_->UpdateRegisteredInvalidationIds(this, ObjectIdSet())); | 270 CHECK(invalidator_->UpdateRegisteredInvalidationIds(this, ObjectIdSet())); |
| 276 } | 271 } |
| 277 } | 272 } |
| 278 | 273 |
| 279 ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes( | 274 ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes( |
| 280 ConfigureReason reason, | 275 ConfigureReason reason, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 ready_task, retry_callback); | 379 ready_task, retry_callback); |
| 385 | 380 |
| 386 DCHECK(Intersection(active_types, types_to_purge).Empty()); | 381 DCHECK(Intersection(active_types, types_to_purge).Empty()); |
| 387 DCHECK(Intersection(active_types, fatal_types).Empty()); | 382 DCHECK(Intersection(active_types, fatal_types).Empty()); |
| 388 DCHECK(Intersection(active_types, unapply_types).Empty()); | 383 DCHECK(Intersection(active_types, unapply_types).Empty()); |
| 389 DCHECK(Intersection(active_types, inactive_types).Empty()); | 384 DCHECK(Intersection(active_types, inactive_types).Empty()); |
| 390 return Difference(active_types, types_to_download); | 385 return Difference(active_types, types_to_download); |
| 391 } | 386 } |
| 392 | 387 |
| 393 void SyncBackendHostImpl::EnableEncryptEverything() { | 388 void SyncBackendHostImpl::EnableEncryptEverything() { |
| 394 sync_thread_->task_runner()->PostTask( | 389 sync_task_runner_->PostTask( |
| 395 FROM_HERE, | 390 FROM_HERE, |
| 396 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_)); | 391 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_)); |
| 397 } | 392 } |
| 398 | 393 |
| 399 void SyncBackendHostImpl::ActivateDirectoryDataType( | 394 void SyncBackendHostImpl::ActivateDirectoryDataType( |
| 400 ModelType type, | 395 ModelType type, |
| 401 ModelSafeGroup group, | 396 ModelSafeGroup group, |
| 402 ChangeProcessor* change_processor) { | 397 ChangeProcessor* change_processor) { |
| 403 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); | 398 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); |
| 404 } | 399 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (initialized()) { | 456 if (initialized()) { |
| 462 CHECK(registrar_.get()); | 457 CHECK(registrar_.get()); |
| 463 registrar_->GetModelSafeRoutingInfo(out); | 458 registrar_->GetModelSafeRoutingInfo(out); |
| 464 } else { | 459 } else { |
| 465 NOTREACHED(); | 460 NOTREACHED(); |
| 466 } | 461 } |
| 467 } | 462 } |
| 468 | 463 |
| 469 void SyncBackendHostImpl::FlushDirectory() const { | 464 void SyncBackendHostImpl::FlushDirectory() const { |
| 470 DCHECK(initialized()); | 465 DCHECK(initialized()); |
| 471 sync_thread_->task_runner()->PostTask( | 466 sync_task_runner_->PostTask( |
| 472 FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_)); | 467 FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_)); |
| 473 } | 468 } |
| 474 | 469 |
| 475 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { | 470 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { |
| 476 sync_thread_->task_runner()->PostTask( | 471 sync_task_runner_->PostTask( |
| 477 FROM_HERE, | 472 FROM_HERE, |
| 478 base::Bind( | 473 base::Bind( |
| 479 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding, | 474 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding, |
| 480 core_)); | 475 core_)); |
| 481 } | 476 } |
| 482 | 477 |
| 483 void SyncBackendHostImpl::DisableProtocolEventForwarding() { | 478 void SyncBackendHostImpl::DisableProtocolEventForwarding() { |
| 484 sync_thread_->task_runner()->PostTask( | 479 sync_task_runner_->PostTask( |
| 485 FROM_HERE, | 480 FROM_HERE, |
| 486 base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_)); | 481 base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_)); |
| 487 } | 482 } |
| 488 | 483 |
| 489 void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() { | 484 void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() { |
| 490 DCHECK(initialized()); | 485 DCHECK(initialized()); |
| 491 sync_thread_->task_runner()->PostTask( | 486 sync_task_runner_->PostTask( |
| 492 FROM_HERE, | 487 FROM_HERE, |
| 493 base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding, | 488 base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding, |
| 494 core_)); | 489 core_)); |
| 495 } | 490 } |
| 496 | 491 |
| 497 void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() { | 492 void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() { |
| 498 DCHECK(initialized()); | 493 DCHECK(initialized()); |
| 499 sync_thread_->task_runner()->PostTask( | 494 sync_task_runner_->PostTask( |
| 500 FROM_HERE, | 495 FROM_HERE, |
| 501 base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding, | 496 base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding, |
| 502 core_)); | 497 core_)); |
| 503 } | 498 } |
| 504 | 499 |
| 505 void SyncBackendHostImpl::InitCore( | 500 void SyncBackendHostImpl::InitCore( |
| 506 std::unique_ptr<DoInitializeOptions> options) { | 501 std::unique_ptr<DoInitializeOptions> options) { |
| 507 sync_thread_->task_runner()->PostTask( | 502 sync_task_runner_->PostTask( |
| 508 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_, | 503 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_, |
| 509 base::Passed(&options))); | 504 base::Passed(&options))); |
| 510 } | 505 } |
| 511 | 506 |
| 512 void SyncBackendHostImpl::RequestConfigureSyncer( | 507 void SyncBackendHostImpl::RequestConfigureSyncer( |
| 513 ConfigureReason reason, | 508 ConfigureReason reason, |
| 514 ModelTypeSet to_download, | 509 ModelTypeSet to_download, |
| 515 ModelTypeSet to_purge, | 510 ModelTypeSet to_purge, |
| 516 ModelTypeSet to_journal, | 511 ModelTypeSet to_journal, |
| 517 ModelTypeSet to_unapply, | 512 ModelTypeSet to_unapply, |
| 518 ModelTypeSet to_ignore, | 513 ModelTypeSet to_ignore, |
| 519 const ModelSafeRoutingInfo& routing_info, | 514 const ModelSafeRoutingInfo& routing_info, |
| 520 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, | 515 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, |
| 521 const base::Closure& retry_callback) { | 516 const base::Closure& retry_callback) { |
| 522 DoConfigureSyncerTypes config_types; | 517 DoConfigureSyncerTypes config_types; |
| 523 config_types.to_download = to_download; | 518 config_types.to_download = to_download; |
| 524 config_types.to_purge = to_purge; | 519 config_types.to_purge = to_purge; |
| 525 config_types.to_journal = to_journal; | 520 config_types.to_journal = to_journal; |
| 526 config_types.to_unapply = to_unapply; | 521 config_types.to_unapply = to_unapply; |
| 527 sync_thread_->task_runner()->PostTask( | 522 sync_task_runner_->PostTask( |
| 528 FROM_HERE, | 523 FROM_HERE, |
| 529 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason, | 524 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason, |
| 530 config_types, routing_info, ready_task, retry_callback)); | 525 config_types, routing_info, ready_task, retry_callback)); |
| 531 } | 526 } |
| 532 | 527 |
| 533 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop( | 528 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop( |
| 534 const ModelTypeSet enabled_types, | 529 const ModelTypeSet enabled_types, |
| 535 const ModelTypeSet succeeded_configuration_types, | 530 const ModelTypeSet succeeded_configuration_types, |
| 536 const ModelTypeSet failed_configuration_types, | 531 const ModelTypeSet failed_configuration_types, |
| 537 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { | 532 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 | 638 |
| 644 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( | 639 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( |
| 645 ModelTypeSet types) { | 640 ModelTypeSet types) { |
| 646 if (!frontend_) | 641 if (!frontend_) |
| 647 return; | 642 return; |
| 648 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 643 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 649 frontend_->OnMigrationNeededForTypes(types); | 644 frontend_->OnMigrationNeededForTypes(types); |
| 650 } | 645 } |
| 651 | 646 |
| 652 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { | 647 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { |
| 653 sync_thread_->task_runner()->PostTask( | 648 sync_task_runner_->PostTask( |
| 654 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, | 649 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, |
| 655 core_, state)); | 650 core_, state)); |
| 656 } | 651 } |
| 657 | 652 |
| 658 void SyncBackendHostImpl::OnIncomingInvalidation( | 653 void SyncBackendHostImpl::OnIncomingInvalidation( |
| 659 const ObjectIdInvalidationMap& invalidation_map) { | 654 const ObjectIdInvalidationMap& invalidation_map) { |
| 660 sync_thread_->task_runner()->PostTask( | 655 sync_task_runner_->PostTask( |
| 661 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation, | 656 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation, |
| 662 core_, invalidation_map)); | 657 core_, invalidation_map)); |
| 663 } | 658 } |
| 664 | 659 |
| 665 std::string SyncBackendHostImpl::GetOwnerName() const { | 660 std::string SyncBackendHostImpl::GetOwnerName() const { |
| 666 return "SyncBackendHostImpl"; | 661 return "SyncBackendHostImpl"; |
| 667 } | 662 } |
| 668 | 663 |
| 669 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys( | 664 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys( |
| 670 const std::string& passphrase) const { | 665 const std::string& passphrase) const { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 } | 774 } |
| 780 | 775 |
| 781 void SyncBackendHostImpl::UpdateInvalidationVersions( | 776 void SyncBackendHostImpl::UpdateInvalidationVersions( |
| 782 const std::map<ModelType, int64_t>& invalidation_versions) { | 777 const std::map<ModelType, int64_t>& invalidation_versions) { |
| 783 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); | 778 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); |
| 784 } | 779 } |
| 785 | 780 |
| 786 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { | 781 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { |
| 787 DCHECK(ui_thread_->BelongsToCurrentThread()); | 782 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 788 | 783 |
| 789 sync_thread_->task_runner()->PostTask( | 784 sync_task_runner_->PostTask( |
| 790 FROM_HERE, | 785 FROM_HERE, |
| 791 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); | 786 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); |
| 792 } | 787 } |
| 793 | 788 |
| 794 void SyncBackendHostImpl::ClearServerData( | 789 void SyncBackendHostImpl::ClearServerData( |
| 795 const SyncManager::ClearServerDataCallback& callback) { | 790 const SyncManager::ClearServerDataCallback& callback) { |
| 796 DCHECK(ui_thread_->BelongsToCurrentThread()); | 791 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 797 sync_thread_->task_runner()->PostTask( | 792 sync_task_runner_->PostTask( |
| 798 FROM_HERE, | 793 FROM_HERE, |
| 799 base::Bind(&SyncBackendHostCore::DoClearServerData, core_, callback)); | 794 base::Bind(&SyncBackendHostCore::DoClearServerData, core_, callback)); |
| 800 } | 795 } |
| 801 | 796 |
| 802 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch, | 797 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch, |
| 803 bool empty_jar) { | 798 bool empty_jar) { |
| 804 DCHECK(ui_thread_->BelongsToCurrentThread()); | 799 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 805 sync_thread_->task_runner()->PostTask( | 800 sync_task_runner_->PostTask( |
| 806 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, core_, | 801 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, core_, |
| 807 account_mismatch, empty_jar)); | 802 account_mismatch, empty_jar)); |
| 808 } | 803 } |
| 809 | 804 |
| 810 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop( | 805 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop( |
| 811 const SyncManager::ClearServerDataCallback& frontend_callback) { | 806 const SyncManager::ClearServerDataCallback& frontend_callback) { |
| 812 DCHECK(ui_thread_->BelongsToCurrentThread()); | 807 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 813 frontend_callback.Run(); | 808 frontend_callback.Run(); |
| 814 } | 809 } |
| 815 | 810 |
| 816 } // namespace syncer | 811 } // namespace syncer |
| 817 | 812 |
| 818 #undef SDVLOG | 813 #undef SDVLOG |
| 819 | 814 |
| 820 #undef SLOG | 815 #undef SLOG |
| OLD | NEW |