| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #define SLOG(severity) LOG(severity) << name_ << ": " | 39 #define SLOG(severity) LOG(severity) << name_ << ": " |
| 40 | 40 |
| 41 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " | 41 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " |
| 42 | 42 |
| 43 namespace syncer { | 43 namespace syncer { |
| 44 | 44 |
| 45 SyncBackendHostImpl::SyncBackendHostImpl( | 45 SyncBackendHostImpl::SyncBackendHostImpl( |
| 46 const std::string& name, | 46 const std::string& name, |
| 47 SyncClient* sync_client, | 47 SyncClient* sync_client, |
| 48 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | |
| 49 invalidation::InvalidationService* invalidator, | 48 invalidation::InvalidationService* invalidator, |
| 50 const base::WeakPtr<SyncPrefs>& sync_prefs, | 49 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 51 const base::FilePath& sync_folder) | 50 const base::FilePath& sync_folder) |
| 52 : frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 51 : sync_client_(sync_client), |
| 53 sync_client_(sync_client), | |
| 54 ui_thread_(ui_thread), | |
| 55 name_(name), | 52 name_(name), |
| 56 initialized_(false), | 53 initialized_(false), |
| 57 sync_prefs_(sync_prefs), | 54 sync_prefs_(sync_prefs), |
| 58 frontend_(nullptr), | 55 frontend_(nullptr), |
| 59 cached_passphrase_type_(PassphraseType::IMPLICIT_PASSPHRASE), | 56 cached_passphrase_type_(PassphraseType::IMPLICIT_PASSPHRASE), |
| 60 invalidator_(invalidator), | 57 invalidator_(invalidator), |
| 61 invalidation_handler_registered_(false), | 58 invalidation_handler_registered_(false), |
| 62 weak_ptr_factory_(this) { | 59 weak_ptr_factory_(this) { |
| 63 core_ = new SyncBackendHostCore(name_, sync_folder, | 60 core_ = new SyncBackendHostCore(name_, sync_folder, |
| 64 sync_prefs_->IsFirstSetupComplete(), | |
| 65 weak_ptr_factory_.GetWeakPtr()); | 61 weak_ptr_factory_.GetWeakPtr()); |
| 66 } | 62 } |
| 67 | 63 |
| 68 SyncBackendHostImpl::~SyncBackendHostImpl() { | 64 SyncBackendHostImpl::~SyncBackendHostImpl() { |
| 69 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor."; | 65 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor."; |
| 70 DCHECK(!registrar_.get()); | 66 DCHECK(!registrar_.get()); |
| 71 } | 67 } |
| 72 | 68 |
| 73 void SyncBackendHostImpl::Initialize( | 69 void SyncBackendHostImpl::Initialize( |
| 74 SyncFrontend* frontend, | 70 SyncFrontend* frontend, |
| 75 base::Thread* sync_thread, | 71 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, |
| 76 const WeakHandle<JsEventHandler>& event_handler, | 72 const WeakHandle<JsEventHandler>& event_handler, |
| 77 const GURL& sync_service_url, | 73 const GURL& sync_service_url, |
| 78 const std::string& sync_user_agent, | 74 const std::string& sync_user_agent, |
| 79 const SyncCredentials& credentials, | 75 const SyncCredentials& credentials, |
| 80 bool delete_sync_data_folder, | 76 bool delete_sync_data_folder, |
| 81 bool enable_local_sync_backend, | 77 bool enable_local_sync_backend, |
| 82 const base::FilePath& local_sync_backend_folder, | 78 const base::FilePath& local_sync_backend_folder, |
| 83 std::unique_ptr<SyncManagerFactory> sync_manager_factory, | 79 std::unique_ptr<SyncManagerFactory> sync_manager_factory, |
| 84 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | 80 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
| 85 const base::Closure& report_unrecoverable_error_function, | 81 const base::Closure& report_unrecoverable_error_function, |
| 86 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 82 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 87 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { | 83 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { |
| 88 CHECK(sync_thread); | 84 CHECK(sync_task_runner); |
| 89 sync_thread_ = sync_thread; | 85 sync_task_runner_ = sync_task_runner; |
| 90 | 86 |
| 91 registrar_ = base::MakeUnique<SyncBackendRegistrar>( | 87 registrar_ = base::MakeUnique<SyncBackendRegistrar>( |
| 92 name_, base::Bind(&SyncClient::CreateModelWorkerForGroup, | 88 name_, base::Bind(&SyncClient::CreateModelWorkerForGroup, |
| 93 base::Unretained(sync_client_))); | 89 base::Unretained(sync_client_))); |
| 94 | 90 |
| 95 DCHECK(frontend); | 91 DCHECK(frontend); |
| 96 frontend_ = frontend; | 92 frontend_ = frontend; |
| 97 | 93 |
| 98 std::vector<scoped_refptr<ModelSafeWorker>> workers; | 94 std::vector<scoped_refptr<ModelSafeWorker>> workers; |
| 99 registrar_->GetWorkers(&workers); | 95 registrar_->GetWorkers(&workers); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 113 } | 109 } |
| 114 if (cl->HasSwitch(switches::kSyncShortNudgeDelayForTest)) { | 110 if (cl->HasSwitch(switches::kSyncShortNudgeDelayForTest)) { |
| 115 factory_switches.nudge_delay = | 111 factory_switches.nudge_delay = |
| 116 EngineComponentsFactory::NudgeDelay::SHORT_NUDGE_DELAY; | 112 EngineComponentsFactory::NudgeDelay::SHORT_NUDGE_DELAY; |
| 117 } | 113 } |
| 118 | 114 |
| 119 std::map<ModelType, int64_t> invalidation_versions; | 115 std::map<ModelType, int64_t> invalidation_versions; |
| 120 sync_prefs_->GetInvalidationVersions(&invalidation_versions); | 116 sync_prefs_->GetInvalidationVersions(&invalidation_versions); |
| 121 | 117 |
| 122 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( | 118 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( |
| 123 sync_thread_->message_loop(), registrar_.get(), workers, | 119 sync_task_runner_, registrar_.get(), workers, |
| 124 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, | 120 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, |
| 125 sync_user_agent, http_post_provider_factory_getter.Run( | 121 sync_user_agent, http_post_provider_factory_getter.Run( |
| 126 core_->GetRequestContextCancelationSignal()), | 122 core_->GetRequestContextCancelationSignal()), |
| 127 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", | 123 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", |
| 128 std::move(sync_manager_factory), delete_sync_data_folder, | 124 std::move(sync_manager_factory), delete_sync_data_folder, |
| 129 enable_local_sync_backend, local_sync_backend_folder, | 125 enable_local_sync_backend, local_sync_backend_folder, |
| 130 sync_prefs_->GetEncryptionBootstrapToken(), | 126 sync_prefs_->GetEncryptionBootstrapToken(), |
| 131 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), | 127 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), |
| 132 std::unique_ptr<EngineComponentsFactory>( | 128 std::unique_ptr<EngineComponentsFactory>( |
| 133 new EngineComponentsFactoryImpl(factory_switches)), | 129 new EngineComponentsFactoryImpl(factory_switches)), |
| 134 unrecoverable_error_handler, report_unrecoverable_error_function, | 130 unrecoverable_error_handler, report_unrecoverable_error_function, |
| 135 std::move(saved_nigori_state), invalidation_versions)); | 131 std::move(saved_nigori_state), invalidation_versions)); |
| 136 InitCore(std::move(init_opts)); | 132 InitCore(std::move(init_opts)); |
| 137 } | 133 } |
| 138 | 134 |
| 139 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { | 135 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { |
| 140 DCHECK(ui_thread_->BelongsToCurrentThread()); | 136 DCHECK(thread_checker_.CalledOnValidThread()); |
| 141 sync_thread_->task_runner()->PostTask( | 137 sync_task_runner_->PostTask( |
| 142 FROM_HERE, | 138 FROM_HERE, |
| 143 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); | 139 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); |
| 144 } | 140 } |
| 145 | 141 |
| 146 void SyncBackendHostImpl::UpdateCredentials( | 142 void SyncBackendHostImpl::UpdateCredentials( |
| 147 const SyncCredentials& credentials) { | 143 const SyncCredentials& credentials) { |
| 148 DCHECK(sync_thread_->IsRunning()); | 144 sync_task_runner_->PostTask( |
| 149 sync_thread_->task_runner()->PostTask( | |
| 150 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, core_, | 145 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, core_, |
| 151 credentials)); | 146 credentials)); |
| 152 } | 147 } |
| 153 | 148 |
| 154 void SyncBackendHostImpl::StartSyncingWithServer() { | 149 void SyncBackendHostImpl::StartSyncingWithServer() { |
| 155 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; | 150 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; |
| 156 | 151 |
| 157 ModelSafeRoutingInfo routing_info; | 152 ModelSafeRoutingInfo routing_info; |
| 158 registrar_->GetModelSafeRoutingInfo(&routing_info); | 153 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 159 | 154 |
| 160 sync_thread_->task_runner()->PostTask( | 155 sync_task_runner_->PostTask( |
| 161 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_, | 156 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_, |
| 162 routing_info, sync_prefs_->GetLastPollTime())); | 157 routing_info, sync_prefs_->GetLastPollTime())); |
| 163 } | 158 } |
| 164 | 159 |
| 165 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase, | 160 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase, |
| 166 bool is_explicit) { | 161 bool is_explicit) { |
| 167 DCHECK(sync_thread_->IsRunning()); | |
| 168 if (!IsNigoriEnabled()) { | 162 if (!IsNigoriEnabled()) { |
| 169 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" | 163 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" |
| 170 " is disabled."; | 164 " is disabled."; |
| 171 return; | 165 return; |
| 172 } | 166 } |
| 173 | 167 |
| 174 // We should never be called with an empty passphrase. | 168 // We should never be called with an empty passphrase. |
| 175 DCHECK(!passphrase.empty()); | 169 DCHECK(!passphrase.empty()); |
| 176 | 170 |
| 177 // This should only be called by the frontend. | 171 // This should only be called by the frontend. |
| 178 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 172 DCHECK(thread_checker_.CalledOnValidThread()); |
| 179 | 173 |
| 180 // SetEncryptionPassphrase should never be called if we are currently | 174 // SetEncryptionPassphrase should never be called if we are currently |
| 181 // encrypted with an explicit passphrase. | 175 // encrypted with an explicit passphrase. |
| 182 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || | 176 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || |
| 183 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); | 177 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); |
| 184 | 178 |
| 185 // Post an encryption task on the syncer thread. | 179 // Post an encryption task on the syncer thread. |
| 186 sync_thread_->task_runner()->PostTask( | 180 sync_task_runner_->PostTask( |
| 187 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, | 181 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, |
| 188 core_, passphrase, is_explicit)); | 182 core_, passphrase, is_explicit)); |
| 189 } | 183 } |
| 190 | 184 |
| 191 bool SyncBackendHostImpl::SetDecryptionPassphrase( | 185 bool SyncBackendHostImpl::SetDecryptionPassphrase( |
| 192 const std::string& passphrase) { | 186 const std::string& passphrase) { |
| 193 if (!IsNigoriEnabled()) { | 187 if (!IsNigoriEnabled()) { |
| 194 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" | 188 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" |
| 195 " is disabled."; | 189 " is disabled."; |
| 196 return false; | 190 return false; |
| 197 } | 191 } |
| 198 | 192 |
| 199 // We should never be called with an empty passphrase. | 193 // We should never be called with an empty passphrase. |
| 200 DCHECK(!passphrase.empty()); | 194 DCHECK(!passphrase.empty()); |
| 201 | 195 |
| 202 // This should only be called by the frontend. | 196 // This should only be called by the frontend. |
| 203 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 197 DCHECK(thread_checker_.CalledOnValidThread()); |
| 204 | 198 |
| 205 // This should only be called when we have cached pending keys. | 199 // This should only be called when we have cached pending keys. |
| 206 DCHECK(cached_pending_keys_.has_blob()); | 200 DCHECK(cached_pending_keys_.has_blob()); |
| 207 | 201 |
| 208 // Check the passphrase that was provided against our local cache of the | 202 // 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 | 203 // cryptographer's pending keys. If this was unsuccessful, the UI layer can |
| 210 // immediately call OnPassphraseRequired without showing the user a spinner. | 204 // immediately call OnPassphraseRequired without showing the user a spinner. |
| 211 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) | 205 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) |
| 212 return false; | 206 return false; |
| 213 | 207 |
| 214 // Post a decryption task on the syncer thread. | 208 // Post a decryption task on the syncer thread. |
| 215 sync_thread_->task_runner()->PostTask( | 209 sync_task_runner_->PostTask( |
| 216 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, | 210 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, |
| 217 core_, passphrase)); | 211 core_, passphrase)); |
| 218 | 212 |
| 219 // Since we were able to decrypt the cached pending keys with the passphrase | 213 // 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 | 214 // provided, we immediately alert the UI layer that the passphrase was |
| 221 // accepted. This will avoid the situation where a user enters a passphrase, | 215 // accepted. This will avoid the situation where a user enters a passphrase, |
| 222 // clicks OK, immediately reopens the advanced settings dialog, and gets an | 216 // clicks OK, immediately reopens the advanced settings dialog, and gets an |
| 223 // unnecessary prompt for a passphrase. | 217 // unnecessary prompt for a passphrase. |
| 224 // Note: It is not guaranteed that the passphrase will be accepted by the | 218 // 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 | 219 // 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 | 220 // pending. This scenario is a valid race, and SetDecryptionPassphrase can |
| 227 // trigger a new OnPassphraseRequired if it needs to. | 221 // trigger a new OnPassphraseRequired if it needs to. |
| 228 NotifyPassphraseAccepted(); | 222 NotifyPassphraseAccepted(); |
| 229 return true; | 223 return true; |
| 230 } | 224 } |
| 231 | 225 |
| 232 void SyncBackendHostImpl::StopSyncingForShutdown() { | 226 void SyncBackendHostImpl::StopSyncingForShutdown() { |
| 233 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 227 DCHECK(thread_checker_.CalledOnValidThread()); |
| 234 | 228 |
| 229 // Stop getting messages from the sync thread. |
| 230 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 235 // Immediately stop sending messages to the frontend. | 231 // Immediately stop sending messages to the frontend. |
| 236 frontend_ = nullptr; | 232 frontend_ = nullptr; |
| 237 | 233 |
| 238 DCHECK(sync_thread_->IsRunning()); | |
| 239 | |
| 240 registrar_->RequestWorkerStopOnUIThread(); | 234 registrar_->RequestWorkerStopOnUIThread(); |
| 241 | 235 |
| 242 core_->ShutdownOnUIThread(); | 236 core_->ShutdownOnUIThread(); |
| 243 } | 237 } |
| 244 | 238 |
| 245 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) { | 239 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) { |
| 246 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | 240 // StopSyncingForShutdown() (which nulls out |frontend_|) should be |
| 247 // called first. | 241 // called first. |
| 248 DCHECK(!frontend_); | 242 DCHECK(!frontend_); |
| 249 DCHECK(sync_thread_->IsRunning()); | |
| 250 | 243 |
| 251 if (invalidation_handler_registered_) { | 244 if (invalidation_handler_registered_) { |
| 252 if (reason == DISABLE_SYNC) { | 245 if (reason == DISABLE_SYNC) { |
| 253 UnregisterInvalidationIds(); | 246 UnregisterInvalidationIds(); |
| 254 } | 247 } |
| 255 invalidator_->UnregisterInvalidationHandler(this); | 248 invalidator_->UnregisterInvalidationHandler(this); |
| 256 invalidator_ = nullptr; | 249 invalidator_ = nullptr; |
| 257 } | 250 } |
| 258 invalidation_handler_registered_ = false; | 251 invalidation_handler_registered_ = false; |
| 259 | 252 |
| 260 model_type_connector_.reset(); | 253 model_type_connector_.reset(); |
| 261 | 254 |
| 262 // Shut down and destroy SyncManager. SyncManager holds a pointer to | 255 // Shut down and destroy SyncManager. SyncManager holds a pointer to |
| 263 // |registrar_| so its destruction must be sequenced before the destruction of | 256 // |registrar_| so its destruction must be sequenced before the destruction of |
| 264 // |registrar_|. | 257 // |registrar_|. |
| 265 sync_thread_->task_runner()->PostTask( | 258 sync_task_runner_->PostTask( |
| 266 FROM_HERE, base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason)); | 259 FROM_HERE, base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason)); |
| 267 core_ = nullptr; | 260 core_ = nullptr; |
| 268 | 261 |
| 269 // Destroy |registrar_|. | 262 // Destroy |registrar_|. |
| 270 sync_thread_->task_runner()->DeleteSoon(FROM_HERE, registrar_.release()); | 263 sync_task_runner_->DeleteSoon(FROM_HERE, registrar_.release()); |
| 271 } | 264 } |
| 272 | 265 |
| 273 void SyncBackendHostImpl::UnregisterInvalidationIds() { | 266 void SyncBackendHostImpl::UnregisterInvalidationIds() { |
| 274 if (invalidation_handler_registered_) { | 267 if (invalidation_handler_registered_) { |
| 275 CHECK(invalidator_->UpdateRegisteredInvalidationIds(this, ObjectIdSet())); | 268 CHECK(invalidator_->UpdateRegisteredInvalidationIds(this, ObjectIdSet())); |
| 276 } | 269 } |
| 277 } | 270 } |
| 278 | 271 |
| 279 ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes( | 272 ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes( |
| 280 ConfigureReason reason, | 273 ConfigureReason reason, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 ready_task, retry_callback); | 377 ready_task, retry_callback); |
| 385 | 378 |
| 386 DCHECK(Intersection(active_types, types_to_purge).Empty()); | 379 DCHECK(Intersection(active_types, types_to_purge).Empty()); |
| 387 DCHECK(Intersection(active_types, fatal_types).Empty()); | 380 DCHECK(Intersection(active_types, fatal_types).Empty()); |
| 388 DCHECK(Intersection(active_types, unapply_types).Empty()); | 381 DCHECK(Intersection(active_types, unapply_types).Empty()); |
| 389 DCHECK(Intersection(active_types, inactive_types).Empty()); | 382 DCHECK(Intersection(active_types, inactive_types).Empty()); |
| 390 return Difference(active_types, types_to_download); | 383 return Difference(active_types, types_to_download); |
| 391 } | 384 } |
| 392 | 385 |
| 393 void SyncBackendHostImpl::EnableEncryptEverything() { | 386 void SyncBackendHostImpl::EnableEncryptEverything() { |
| 394 sync_thread_->task_runner()->PostTask( | 387 sync_task_runner_->PostTask( |
| 395 FROM_HERE, | 388 FROM_HERE, |
| 396 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_)); | 389 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_)); |
| 397 } | 390 } |
| 398 | 391 |
| 399 void SyncBackendHostImpl::ActivateDirectoryDataType( | 392 void SyncBackendHostImpl::ActivateDirectoryDataType( |
| 400 ModelType type, | 393 ModelType type, |
| 401 ModelSafeGroup group, | 394 ModelSafeGroup group, |
| 402 ChangeProcessor* change_processor) { | 395 ChangeProcessor* change_processor) { |
| 403 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); | 396 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); |
| 404 } | 397 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 if (initialized()) { | 454 if (initialized()) { |
| 462 CHECK(registrar_.get()); | 455 CHECK(registrar_.get()); |
| 463 registrar_->GetModelSafeRoutingInfo(out); | 456 registrar_->GetModelSafeRoutingInfo(out); |
| 464 } else { | 457 } else { |
| 465 NOTREACHED(); | 458 NOTREACHED(); |
| 466 } | 459 } |
| 467 } | 460 } |
| 468 | 461 |
| 469 void SyncBackendHostImpl::FlushDirectory() const { | 462 void SyncBackendHostImpl::FlushDirectory() const { |
| 470 DCHECK(initialized()); | 463 DCHECK(initialized()); |
| 471 sync_thread_->task_runner()->PostTask( | 464 sync_task_runner_->PostTask( |
| 472 FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_)); | 465 FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_)); |
| 473 } | 466 } |
| 474 | 467 |
| 475 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { | 468 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { |
| 476 sync_thread_->task_runner()->PostTask( | 469 sync_task_runner_->PostTask( |
| 477 FROM_HERE, | 470 FROM_HERE, |
| 478 base::Bind( | 471 base::Bind( |
| 479 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding, | 472 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding, |
| 480 core_)); | 473 core_)); |
| 481 } | 474 } |
| 482 | 475 |
| 483 void SyncBackendHostImpl::DisableProtocolEventForwarding() { | 476 void SyncBackendHostImpl::DisableProtocolEventForwarding() { |
| 484 sync_thread_->task_runner()->PostTask( | 477 sync_task_runner_->PostTask( |
| 485 FROM_HERE, | 478 FROM_HERE, |
| 486 base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_)); | 479 base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_)); |
| 487 } | 480 } |
| 488 | 481 |
| 489 void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() { | 482 void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() { |
| 490 DCHECK(initialized()); | 483 DCHECK(initialized()); |
| 491 sync_thread_->task_runner()->PostTask( | 484 sync_task_runner_->PostTask( |
| 492 FROM_HERE, | 485 FROM_HERE, |
| 493 base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding, | 486 base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding, |
| 494 core_)); | 487 core_)); |
| 495 } | 488 } |
| 496 | 489 |
| 497 void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() { | 490 void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() { |
| 498 DCHECK(initialized()); | 491 DCHECK(initialized()); |
| 499 sync_thread_->task_runner()->PostTask( | 492 sync_task_runner_->PostTask( |
| 500 FROM_HERE, | 493 FROM_HERE, |
| 501 base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding, | 494 base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding, |
| 502 core_)); | 495 core_)); |
| 503 } | 496 } |
| 504 | 497 |
| 505 void SyncBackendHostImpl::InitCore( | 498 void SyncBackendHostImpl::InitCore( |
| 506 std::unique_ptr<DoInitializeOptions> options) { | 499 std::unique_ptr<DoInitializeOptions> options) { |
| 507 sync_thread_->task_runner()->PostTask( | 500 sync_task_runner_->PostTask( |
| 508 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_, | 501 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_, |
| 509 base::Passed(&options))); | 502 base::Passed(&options))); |
| 510 } | 503 } |
| 511 | 504 |
| 512 void SyncBackendHostImpl::RequestConfigureSyncer( | 505 void SyncBackendHostImpl::RequestConfigureSyncer( |
| 513 ConfigureReason reason, | 506 ConfigureReason reason, |
| 514 ModelTypeSet to_download, | 507 ModelTypeSet to_download, |
| 515 ModelTypeSet to_purge, | 508 ModelTypeSet to_purge, |
| 516 ModelTypeSet to_journal, | 509 ModelTypeSet to_journal, |
| 517 ModelTypeSet to_unapply, | 510 ModelTypeSet to_unapply, |
| 518 ModelTypeSet to_ignore, | 511 ModelTypeSet to_ignore, |
| 519 const ModelSafeRoutingInfo& routing_info, | 512 const ModelSafeRoutingInfo& routing_info, |
| 520 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, | 513 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, |
| 521 const base::Closure& retry_callback) { | 514 const base::Closure& retry_callback) { |
| 522 DoConfigureSyncerTypes config_types; | 515 DoConfigureSyncerTypes config_types; |
| 523 config_types.to_download = to_download; | 516 config_types.to_download = to_download; |
| 524 config_types.to_purge = to_purge; | 517 config_types.to_purge = to_purge; |
| 525 config_types.to_journal = to_journal; | 518 config_types.to_journal = to_journal; |
| 526 config_types.to_unapply = to_unapply; | 519 config_types.to_unapply = to_unapply; |
| 527 sync_thread_->task_runner()->PostTask( | 520 sync_task_runner_->PostTask( |
| 528 FROM_HERE, | 521 FROM_HERE, |
| 529 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason, | 522 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason, |
| 530 config_types, routing_info, ready_task, retry_callback)); | 523 config_types, routing_info, ready_task, retry_callback)); |
| 531 } | 524 } |
| 532 | 525 |
| 533 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop( | 526 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop( |
| 534 const ModelTypeSet enabled_types, | 527 const ModelTypeSet enabled_types, |
| 535 const ModelTypeSet succeeded_configuration_types, | 528 const ModelTypeSet succeeded_configuration_types, |
| 536 const ModelTypeSet failed_configuration_types, | 529 const ModelTypeSet failed_configuration_types, |
| 537 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { | 530 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 552 Experiments experiments; | 545 Experiments experiments; |
| 553 if (core_->sync_manager()->ReceivedExperiment(&experiments)) | 546 if (core_->sync_manager()->ReceivedExperiment(&experiments)) |
| 554 frontend_->OnExperimentsChanged(experiments); | 547 frontend_->OnExperimentsChanged(experiments); |
| 555 } | 548 } |
| 556 | 549 |
| 557 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( | 550 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( |
| 558 const WeakHandle<JsBackend> js_backend, | 551 const WeakHandle<JsBackend> js_backend, |
| 559 const WeakHandle<DataTypeDebugInfoListener> debug_info_listener, | 552 const WeakHandle<DataTypeDebugInfoListener> debug_info_listener, |
| 560 std::unique_ptr<ModelTypeConnector> model_type_connector, | 553 std::unique_ptr<ModelTypeConnector> model_type_connector, |
| 561 const std::string& cache_guid) { | 554 const std::string& cache_guid) { |
| 562 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 555 DCHECK(thread_checker_.CalledOnValidThread()); |
| 563 | 556 |
| 564 model_type_connector_ = std::move(model_type_connector); | 557 model_type_connector_ = std::move(model_type_connector); |
| 565 | 558 |
| 566 if (!frontend_) | 559 if (!frontend_) |
| 567 return; | 560 return; |
| 568 | 561 |
| 569 initialized_ = true; | 562 initialized_ = true; |
| 570 | 563 |
| 571 if (invalidator_) { | 564 if (invalidator_) { |
| 572 invalidator_->RegisterInvalidationHandler(this); | 565 invalidator_->RegisterInvalidationHandler(this); |
| 573 invalidation_handler_registered_ = true; | 566 invalidation_handler_registered_ = true; |
| 574 | 567 |
| 575 // Fake a state change to initialize the SyncManager's cached invalidator | 568 // Fake a state change to initialize the SyncManager's cached invalidator |
| 576 // state. | 569 // state. |
| 577 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); | 570 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); |
| 578 } | 571 } |
| 579 | 572 |
| 580 // Now that we've downloaded the control types, we can see if there are any | 573 // Now that we've downloaded the control types, we can see if there are any |
| 581 // experimental types to enable. This should be done before we inform | 574 // experimental types to enable. This should be done before we inform |
| 582 // the frontend to ensure they're visible in the customize screen. | 575 // the frontend to ensure they're visible in the customize screen. |
| 583 AddExperimentalTypes(); | 576 AddExperimentalTypes(); |
| 584 frontend_->OnBackendInitialized(js_backend, debug_info_listener, cache_guid, | 577 frontend_->OnBackendInitialized(js_backend, debug_info_listener, cache_guid, |
| 585 true); | 578 true); |
| 586 } | 579 } |
| 587 | 580 |
| 588 void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() { | 581 void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() { |
| 589 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 582 DCHECK(thread_checker_.CalledOnValidThread()); |
| 590 if (!frontend_) | 583 if (!frontend_) |
| 591 return; | 584 return; |
| 592 | 585 |
| 593 frontend_->OnBackendInitialized(WeakHandle<JsBackend>(), | 586 frontend_->OnBackendInitialized(WeakHandle<JsBackend>(), |
| 594 WeakHandle<DataTypeDebugInfoListener>(), "", | 587 WeakHandle<DataTypeDebugInfoListener>(), "", |
| 595 false); | 588 false); |
| 596 } | 589 } |
| 597 | 590 |
| 598 void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop( | 591 void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop( |
| 599 const SyncCycleSnapshot& snapshot) { | 592 const SyncCycleSnapshot& snapshot) { |
| 600 if (!frontend_) | 593 if (!frontend_) |
| 601 return; | 594 return; |
| 602 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 595 DCHECK(thread_checker_.CalledOnValidThread()); |
| 603 | 596 |
| 604 last_snapshot_ = snapshot; | 597 last_snapshot_ = snapshot; |
| 605 | 598 |
| 606 SDVLOG(1) << "Got snapshot " << snapshot.ToString(); | 599 SDVLOG(1) << "Got snapshot " << snapshot.ToString(); |
| 607 | 600 |
| 608 if (!snapshot.poll_finish_time().is_null()) | 601 if (!snapshot.poll_finish_time().is_null()) |
| 609 sync_prefs_->SetLastPollTime(snapshot.poll_finish_time()); | 602 sync_prefs_->SetLastPollTime(snapshot.poll_finish_time()); |
| 610 | 603 |
| 611 // Process any changes to the datatypes we're syncing. | 604 // Process any changes to the datatypes we're syncing. |
| 612 // TODO(sync): add support for removing types. | 605 // TODO(sync): add support for removing types. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 630 if (token_type == PASSPHRASE_BOOTSTRAP_TOKEN) | 623 if (token_type == PASSPHRASE_BOOTSTRAP_TOKEN) |
| 631 sync_prefs_->SetEncryptionBootstrapToken(token); | 624 sync_prefs_->SetEncryptionBootstrapToken(token); |
| 632 else | 625 else |
| 633 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); | 626 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); |
| 634 } | 627 } |
| 635 | 628 |
| 636 void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop( | 629 void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop( |
| 637 const SyncProtocolError& sync_error) { | 630 const SyncProtocolError& sync_error) { |
| 638 if (!frontend_) | 631 if (!frontend_) |
| 639 return; | 632 return; |
| 640 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 633 DCHECK(thread_checker_.CalledOnValidThread()); |
| 641 frontend_->OnActionableError(sync_error); | 634 frontend_->OnActionableError(sync_error); |
| 642 } | 635 } |
| 643 | 636 |
| 644 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( | 637 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( |
| 645 ModelTypeSet types) { | 638 ModelTypeSet types) { |
| 646 if (!frontend_) | 639 if (!frontend_) |
| 647 return; | 640 return; |
| 648 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 641 DCHECK(thread_checker_.CalledOnValidThread()); |
| 649 frontend_->OnMigrationNeededForTypes(types); | 642 frontend_->OnMigrationNeededForTypes(types); |
| 650 } | 643 } |
| 651 | 644 |
| 652 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { | 645 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { |
| 653 sync_thread_->task_runner()->PostTask( | 646 sync_task_runner_->PostTask( |
| 654 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, | 647 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, |
| 655 core_, state)); | 648 core_, state)); |
| 656 } | 649 } |
| 657 | 650 |
| 658 void SyncBackendHostImpl::OnIncomingInvalidation( | 651 void SyncBackendHostImpl::OnIncomingInvalidation( |
| 659 const ObjectIdInvalidationMap& invalidation_map) { | 652 const ObjectIdInvalidationMap& invalidation_map) { |
| 660 sync_thread_->task_runner()->PostTask( | 653 sync_task_runner_->PostTask( |
| 661 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation, | 654 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation, |
| 662 core_, invalidation_map)); | 655 core_, invalidation_map)); |
| 663 } | 656 } |
| 664 | 657 |
| 665 std::string SyncBackendHostImpl::GetOwnerName() const { | 658 std::string SyncBackendHostImpl::GetOwnerName() const { |
| 666 return "SyncBackendHostImpl"; | 659 return "SyncBackendHostImpl"; |
| 667 } | 660 } |
| 668 | 661 |
| 669 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys( | 662 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys( |
| 670 const std::string& passphrase) const { | 663 const std::string& passphrase) const { |
| 671 DCHECK(cached_pending_keys_.has_blob()); | 664 DCHECK(cached_pending_keys_.has_blob()); |
| 672 DCHECK(!passphrase.empty()); | 665 DCHECK(!passphrase.empty()); |
| 673 Nigori nigori; | 666 Nigori nigori; |
| 674 nigori.InitByDerivation("localhost", "dummy", passphrase); | 667 nigori.InitByDerivation("localhost", "dummy", passphrase); |
| 675 std::string plaintext; | 668 std::string plaintext; |
| 676 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); | 669 bool result = nigori.Decrypt(cached_pending_keys_.blob(), &plaintext); |
| 677 DVLOG_IF(1, result) << "Passphrase failed to decrypt pending keys."; | 670 DVLOG_IF(1, result) << "Passphrase failed to decrypt pending keys."; |
| 678 return result; | 671 return result; |
| 679 } | 672 } |
| 680 | 673 |
| 681 void SyncBackendHostImpl::NotifyPassphraseRequired( | 674 void SyncBackendHostImpl::NotifyPassphraseRequired( |
| 682 PassphraseRequiredReason reason, | 675 PassphraseRequiredReason reason, |
| 683 sync_pb::EncryptedData pending_keys) { | 676 sync_pb::EncryptedData pending_keys) { |
| 684 if (!frontend_) | 677 if (!frontend_) |
| 685 return; | 678 return; |
| 686 | 679 |
| 687 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 680 DCHECK(thread_checker_.CalledOnValidThread()); |
| 688 | 681 |
| 689 // Update our cache of the cryptographer's pending keys. | 682 // Update our cache of the cryptographer's pending keys. |
| 690 cached_pending_keys_ = pending_keys; | 683 cached_pending_keys_ = pending_keys; |
| 691 | 684 |
| 692 frontend_->OnPassphraseRequired(reason, pending_keys); | 685 frontend_->OnPassphraseRequired(reason, pending_keys); |
| 693 } | 686 } |
| 694 | 687 |
| 695 void SyncBackendHostImpl::NotifyPassphraseAccepted() { | 688 void SyncBackendHostImpl::NotifyPassphraseAccepted() { |
| 696 if (!frontend_) | 689 if (!frontend_) |
| 697 return; | 690 return; |
| 698 | 691 |
| 699 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 692 DCHECK(thread_checker_.CalledOnValidThread()); |
| 700 | 693 |
| 701 // Clear our cache of the cryptographer's pending keys. | 694 // Clear our cache of the cryptographer's pending keys. |
| 702 cached_pending_keys_.clear_blob(); | 695 cached_pending_keys_.clear_blob(); |
| 703 frontend_->OnPassphraseAccepted(); | 696 frontend_->OnPassphraseAccepted(); |
| 704 } | 697 } |
| 705 | 698 |
| 706 void SyncBackendHostImpl::NotifyEncryptedTypesChanged( | 699 void SyncBackendHostImpl::NotifyEncryptedTypesChanged( |
| 707 ModelTypeSet encrypted_types, | 700 ModelTypeSet encrypted_types, |
| 708 bool encrypt_everything) { | 701 bool encrypt_everything) { |
| 709 if (!frontend_) | 702 if (!frontend_) |
| 710 return; | 703 return; |
| 711 | 704 |
| 712 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 705 DCHECK(thread_checker_.CalledOnValidThread()); |
| 713 frontend_->OnEncryptedTypesChanged(encrypted_types, encrypt_everything); | 706 frontend_->OnEncryptedTypesChanged(encrypted_types, encrypt_everything); |
| 714 } | 707 } |
| 715 | 708 |
| 716 void SyncBackendHostImpl::NotifyEncryptionComplete() { | 709 void SyncBackendHostImpl::NotifyEncryptionComplete() { |
| 717 if (!frontend_) | 710 if (!frontend_) |
| 718 return; | 711 return; |
| 719 | 712 |
| 720 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 713 DCHECK(thread_checker_.CalledOnValidThread()); |
| 721 frontend_->OnEncryptionComplete(); | 714 frontend_->OnEncryptionComplete(); |
| 722 } | 715 } |
| 723 | 716 |
| 724 void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop( | 717 void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop( |
| 725 PassphraseType type, | 718 PassphraseType type, |
| 726 base::Time explicit_passphrase_time) { | 719 base::Time explicit_passphrase_time) { |
| 727 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 720 DCHECK(thread_checker_.CalledOnValidThread()); |
| 728 DVLOG(1) << "Passphrase type changed to " << PassphraseTypeToString(type); | 721 DVLOG(1) << "Passphrase type changed to " << PassphraseTypeToString(type); |
| 729 cached_passphrase_type_ = type; | 722 cached_passphrase_type_ = type; |
| 730 cached_explicit_passphrase_time_ = explicit_passphrase_time; | 723 cached_explicit_passphrase_time_ = explicit_passphrase_time; |
| 731 } | 724 } |
| 732 | 725 |
| 733 void SyncBackendHostImpl::HandleLocalSetPassphraseEncryptionOnFrontendLoop( | 726 void SyncBackendHostImpl::HandleLocalSetPassphraseEncryptionOnFrontendLoop( |
| 734 const SyncEncryptionHandler::NigoriState& nigori_state) { | 727 const SyncEncryptionHandler::NigoriState& nigori_state) { |
| 735 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 728 DCHECK(thread_checker_.CalledOnValidThread()); |
| 736 frontend_->OnLocalSetPassphraseEncryption(nigori_state); | 729 frontend_->OnLocalSetPassphraseEncryption(nigori_state); |
| 737 } | 730 } |
| 738 | 731 |
| 739 void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop( | 732 void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop( |
| 740 ConnectionStatus status) { | 733 ConnectionStatus status) { |
| 741 if (!frontend_) | 734 if (!frontend_) |
| 742 return; | 735 return; |
| 743 | 736 |
| 744 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); | 737 DCHECK(thread_checker_.CalledOnValidThread()); |
| 745 | 738 |
| 746 DVLOG(1) << "Connection status changed: " << ConnectionStatusToString(status); | 739 DVLOG(1) << "Connection status changed: " << ConnectionStatusToString(status); |
| 747 frontend_->OnConnectionStatusChange(status); | 740 frontend_->OnConnectionStatusChange(status); |
| 748 } | 741 } |
| 749 | 742 |
| 750 void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop( | 743 void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop( |
| 751 std::unique_ptr<ProtocolEvent> event) { | 744 std::unique_ptr<ProtocolEvent> event) { |
| 752 if (!frontend_) | 745 if (!frontend_) |
| 753 return; | 746 return; |
| 754 frontend_->OnProtocolEvent(*event); | 747 frontend_->OnProtocolEvent(*event); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 777 return; | 770 return; |
| 778 frontend_->OnDatatypeStatusCounterUpdated(type, counters); | 771 frontend_->OnDatatypeStatusCounterUpdated(type, counters); |
| 779 } | 772 } |
| 780 | 773 |
| 781 void SyncBackendHostImpl::UpdateInvalidationVersions( | 774 void SyncBackendHostImpl::UpdateInvalidationVersions( |
| 782 const std::map<ModelType, int64_t>& invalidation_versions) { | 775 const std::map<ModelType, int64_t>& invalidation_versions) { |
| 783 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); | 776 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); |
| 784 } | 777 } |
| 785 | 778 |
| 786 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { | 779 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { |
| 787 DCHECK(ui_thread_->BelongsToCurrentThread()); | 780 DCHECK(thread_checker_.CalledOnValidThread()); |
| 788 | 781 sync_task_runner_->PostTask( |
| 789 sync_thread_->task_runner()->PostTask( | |
| 790 FROM_HERE, | 782 FROM_HERE, |
| 791 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); | 783 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); |
| 792 } | 784 } |
| 793 | 785 |
| 794 void SyncBackendHostImpl::ClearServerData( | 786 void SyncBackendHostImpl::ClearServerData( |
| 795 const SyncManager::ClearServerDataCallback& callback) { | 787 const SyncManager::ClearServerDataCallback& callback) { |
| 796 DCHECK(ui_thread_->BelongsToCurrentThread()); | 788 DCHECK(thread_checker_.CalledOnValidThread()); |
| 797 sync_thread_->task_runner()->PostTask( | 789 sync_task_runner_->PostTask( |
| 798 FROM_HERE, | 790 FROM_HERE, |
| 799 base::Bind(&SyncBackendHostCore::DoClearServerData, core_, callback)); | 791 base::Bind(&SyncBackendHostCore::DoClearServerData, core_, callback)); |
| 800 } | 792 } |
| 801 | 793 |
| 802 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch, | 794 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch, |
| 803 bool empty_jar) { | 795 bool empty_jar) { |
| 804 DCHECK(ui_thread_->BelongsToCurrentThread()); | 796 DCHECK(thread_checker_.CalledOnValidThread()); |
| 805 sync_thread_->task_runner()->PostTask( | 797 sync_task_runner_->PostTask( |
| 806 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, core_, | 798 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, core_, |
| 807 account_mismatch, empty_jar)); | 799 account_mismatch, empty_jar)); |
| 808 } | 800 } |
| 809 | 801 |
| 810 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop( | 802 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop( |
| 811 const SyncManager::ClearServerDataCallback& frontend_callback) { | 803 const SyncManager::ClearServerDataCallback& frontend_callback) { |
| 812 DCHECK(ui_thread_->BelongsToCurrentThread()); | 804 DCHECK(thread_checker_.CalledOnValidThread()); |
| 813 frontend_callback.Run(); | 805 frontend_callback.Run(); |
| 814 } | 806 } |
| 815 | 807 |
| 816 } // namespace syncer | 808 } // namespace syncer |
| 817 | 809 |
| 818 #undef SDVLOG | 810 #undef SDVLOG |
| 819 | 811 |
| 820 #undef SLOG | 812 #undef SLOG |
| OLD | NEW |