Chromium Code Reviews| 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" |
| 11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "components/invalidation/public/invalidation_service.h" | 16 #include "components/invalidation/public/invalidation_service.h" |
| 17 #include "components/invalidation/public/object_id_invalidation_map.h" | 17 #include "components/invalidation/public/object_id_invalidation_map.h" |
| 18 #include "components/signin/core/browser/signin_client.h" | 18 #include "components/signin/core/browser/signin_client.h" |
| 19 #include "components/sync/base/experiments.h" | 19 #include "components/sync/base/experiments.h" |
| 20 #include "components/sync/base/invalidation_helper.h" | 20 #include "components/sync/base/invalidation_helper.h" |
| 21 #include "components/sync/base/sync_prefs.h" | 21 #include "components/sync/base/sync_prefs.h" |
| 22 #include "components/sync/driver/glue/sync_backend_host_core.h" | 22 #include "components/sync/driver/glue/sync_backend_host_core.h" |
| 23 #include "components/sync/driver/glue/sync_backend_registrar.h" | 23 #include "components/sync/driver/glue/sync_backend_registrar.h" |
| 24 #include "components/sync/driver/sync_client.h" | 24 #include "components/sync/driver/sync_client.h" |
| 25 #include "components/sync/driver/sync_driver_switches.h" | 25 #include "components/sync/driver/sync_driver_switches.h" |
| 26 #include "components/sync/driver/sync_frontend.h" | |
| 27 #include "components/sync/engine/activation_context.h" | 26 #include "components/sync/engine/activation_context.h" |
| 28 #include "components/sync/engine/engine_components_factory.h" | 27 #include "components/sync/engine/engine_components_factory.h" |
| 29 #include "components/sync/engine/engine_components_factory_impl.h" | 28 #include "components/sync/engine/engine_components_factory_impl.h" |
| 30 #include "components/sync/engine/events/protocol_event.h" | 29 #include "components/sync/engine/events/protocol_event.h" |
| 31 #include "components/sync/engine/net/http_bridge.h" | 30 #include "components/sync/engine/net/http_bridge.h" |
| 31 #include "components/sync/engine/sync_engine_host.h" | |
| 32 #include "components/sync/engine/sync_manager_factory.h" | 32 #include "components/sync/engine/sync_manager_factory.h" |
| 33 #include "components/sync/engine/sync_string_conversions.h" | 33 #include "components/sync/engine/sync_string_conversions.h" |
| 34 #include "components/sync/syncable/base_transaction.h" | 34 #include "components/sync/syncable/base_transaction.h" |
| 35 | 35 |
| 36 // Helper macros to log with the syncer thread name; useful when there | 36 // Helper macros to log with the syncer thread name; useful when there |
| 37 // are multiple syncers involved. | 37 // are multiple syncers involved. |
| 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 invalidation::InvalidationService* invalidator, | 48 invalidation::InvalidationService* invalidator, |
| 49 const base::WeakPtr<SyncPrefs>& sync_prefs, | 49 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 50 const base::FilePath& sync_folder) | 50 const base::FilePath& sync_folder) |
| 51 : sync_client_(sync_client), | 51 : sync_client_(sync_client), |
| 52 name_(name), | 52 name_(name), |
| 53 initialized_(false), | |
| 54 sync_prefs_(sync_prefs), | 53 sync_prefs_(sync_prefs), |
| 55 frontend_(nullptr), | |
| 56 cached_passphrase_type_(PassphraseType::IMPLICIT_PASSPHRASE), | |
| 57 invalidator_(invalidator), | 54 invalidator_(invalidator), |
| 58 invalidation_handler_registered_(false), | |
| 59 weak_ptr_factory_(this) { | 55 weak_ptr_factory_(this) { |
| 60 core_ = new SyncBackendHostCore(name_, sync_folder, | 56 core_ = new SyncBackendHostCore(name_, sync_folder, |
| 61 weak_ptr_factory_.GetWeakPtr()); | 57 weak_ptr_factory_.GetWeakPtr()); |
| 62 } | 58 } |
| 63 | 59 |
| 64 SyncBackendHostImpl::~SyncBackendHostImpl() { | 60 SyncBackendHostImpl::~SyncBackendHostImpl() { |
| 65 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor."; | 61 DCHECK(!core_.get() && !host_) << "Must call Shutdown before destructor."; |
| 66 DCHECK(!registrar_.get()); | 62 DCHECK(!registrar_.get()); |
| 67 } | 63 } |
| 68 | 64 |
| 69 void SyncBackendHostImpl::Initialize( | 65 void SyncBackendHostImpl::Initialize( |
| 70 SyncFrontend* frontend, | 66 SyncEngineHost* host, |
| 71 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, | 67 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, |
| 72 const WeakHandle<JsEventHandler>& event_handler, | 68 const WeakHandle<JsEventHandler>& event_handler, |
| 73 const GURL& sync_service_url, | 69 const GURL& sync_service_url, |
| 74 const std::string& sync_user_agent, | 70 const std::string& sync_user_agent, |
| 75 const SyncCredentials& credentials, | 71 const SyncCredentials& credentials, |
| 76 bool delete_sync_data_folder, | 72 bool delete_sync_data_folder, |
| 77 bool enable_local_sync_backend, | 73 bool enable_local_sync_backend, |
| 78 const base::FilePath& local_sync_backend_folder, | 74 const base::FilePath& local_sync_backend_folder, |
| 79 std::unique_ptr<SyncManagerFactory> sync_manager_factory, | 75 std::unique_ptr<SyncManagerFactory> sync_manager_factory, |
| 80 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | 76 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
| 81 const base::Closure& report_unrecoverable_error_function, | 77 const base::Closure& report_unrecoverable_error_function, |
| 82 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 78 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 83 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { | 79 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { |
| 84 CHECK(sync_task_runner); | 80 CHECK(sync_task_runner); |
| 85 sync_task_runner_ = sync_task_runner; | 81 sync_task_runner_ = sync_task_runner; |
| 86 | 82 |
| 87 registrar_ = base::MakeUnique<SyncBackendRegistrar>( | 83 registrar_ = base::MakeUnique<SyncBackendRegistrar>( |
| 88 name_, base::Bind(&SyncClient::CreateModelWorkerForGroup, | 84 name_, base::Bind(&SyncClient::CreateModelWorkerForGroup, |
| 89 base::Unretained(sync_client_))); | 85 base::Unretained(sync_client_))); |
| 90 | 86 |
| 91 DCHECK(frontend); | 87 DCHECK(host); |
| 92 frontend_ = frontend; | 88 host_ = host; |
| 93 | 89 |
| 94 std::vector<scoped_refptr<ModelSafeWorker>> workers; | 90 std::vector<scoped_refptr<ModelSafeWorker>> workers; |
| 95 registrar_->GetWorkers(&workers); | 91 registrar_->GetWorkers(&workers); |
| 96 | 92 |
| 97 EngineComponentsFactory::Switches factory_switches = { | 93 EngineComponentsFactory::Switches factory_switches = { |
| 98 EngineComponentsFactory::ENCRYPTION_KEYSTORE, | 94 EngineComponentsFactory::ENCRYPTION_KEYSTORE, |
| 99 EngineComponentsFactory::BACKOFF_NORMAL}; | 95 EngineComponentsFactory::BACKOFF_NORMAL}; |
| 100 | 96 |
| 101 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 97 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); |
| 102 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { | 98 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 bool is_explicit) { | 157 bool is_explicit) { |
| 162 if (!IsNigoriEnabled()) { | 158 if (!IsNigoriEnabled()) { |
| 163 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" | 159 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" |
| 164 " is disabled."; | 160 " is disabled."; |
| 165 return; | 161 return; |
| 166 } | 162 } |
| 167 | 163 |
| 168 // We should never be called with an empty passphrase. | 164 // We should never be called with an empty passphrase. |
| 169 DCHECK(!passphrase.empty()); | 165 DCHECK(!passphrase.empty()); |
| 170 | 166 |
| 171 // This should only be called by the frontend. | 167 // This should only be called by the host. |
|
skym
2016/12/02 20:54:54
Do we really need this comment? This isn't verifyi
maxbogue
2016/12/02 23:59:27
Removed it. They aren't allowed to be called from
| |
| 172 DCHECK(thread_checker_.CalledOnValidThread()); | 168 DCHECK(thread_checker_.CalledOnValidThread()); |
|
skym
2016/12/02 20:54:54
Is it just me, or is it a bit odd that these Calle
maxbogue
2016/12/02 23:59:27
No you're right. Moved to the top.
| |
| 173 | 169 |
| 174 // SetEncryptionPassphrase should never be called if we are currently | 170 // SetEncryptionPassphrase should never be called if we are currently |
| 175 // encrypted with an explicit passphrase. | 171 // encrypted with an explicit passphrase. |
| 176 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || | 172 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || |
| 177 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); | 173 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); |
| 178 | 174 |
| 179 // Post an encryption task on the syncer thread. | 175 // Post an encryption task on the syncer thread. |
| 180 sync_task_runner_->PostTask( | 176 sync_task_runner_->PostTask( |
| 181 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, | 177 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, |
| 182 core_, passphrase, is_explicit)); | 178 core_, passphrase, is_explicit)); |
| 183 } | 179 } |
| 184 | 180 |
| 185 bool SyncBackendHostImpl::SetDecryptionPassphrase( | 181 bool SyncBackendHostImpl::SetDecryptionPassphrase( |
| 186 const std::string& passphrase) { | 182 const std::string& passphrase) { |
| 187 if (!IsNigoriEnabled()) { | 183 if (!IsNigoriEnabled()) { |
| 188 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" | 184 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" |
| 189 " is disabled."; | 185 " is disabled."; |
| 190 return false; | 186 return false; |
| 191 } | 187 } |
| 192 | 188 |
| 193 // We should never be called with an empty passphrase. | 189 // We should never be called with an empty passphrase. |
| 194 DCHECK(!passphrase.empty()); | 190 DCHECK(!passphrase.empty()); |
| 195 | 191 |
| 196 // This should only be called by the frontend. | 192 // This should only be called by the host. |
|
skym
2016/12/02 20:54:54
Same
maxbogue
2016/12/02 23:59:27
Done.
| |
| 197 DCHECK(thread_checker_.CalledOnValidThread()); | 193 DCHECK(thread_checker_.CalledOnValidThread()); |
|
skym
2016/12/02 20:54:54
Same
maxbogue
2016/12/02 23:59:27
Done.
| |
| 198 | 194 |
| 199 // This should only be called when we have cached pending keys. | 195 // This should only be called when we have cached pending keys. |
| 200 DCHECK(cached_pending_keys_.has_blob()); | 196 DCHECK(cached_pending_keys_.has_blob()); |
| 201 | 197 |
| 202 // Check the passphrase that was provided against our local cache of the | 198 // Check the passphrase that was provided against our local cache of the |
| 203 // cryptographer's pending keys. If this was unsuccessful, the UI layer can | 199 // cryptographer's pending keys. If this was unsuccessful, the UI layer can |
| 204 // immediately call OnPassphraseRequired without showing the user a spinner. | 200 // immediately call OnPassphraseRequired without showing the user a spinner. |
| 205 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) | 201 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) |
| 206 return false; | 202 return false; |
| 207 | 203 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 221 // trigger a new OnPassphraseRequired if it needs to. | 217 // trigger a new OnPassphraseRequired if it needs to. |
| 222 NotifyPassphraseAccepted(); | 218 NotifyPassphraseAccepted(); |
| 223 return true; | 219 return true; |
| 224 } | 220 } |
| 225 | 221 |
| 226 void SyncBackendHostImpl::StopSyncingForShutdown() { | 222 void SyncBackendHostImpl::StopSyncingForShutdown() { |
| 227 DCHECK(thread_checker_.CalledOnValidThread()); | 223 DCHECK(thread_checker_.CalledOnValidThread()); |
| 228 | 224 |
| 229 // Stop getting messages from the sync thread. | 225 // Stop getting messages from the sync thread. |
| 230 weak_ptr_factory_.InvalidateWeakPtrs(); | 226 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 231 // Immediately stop sending messages to the frontend. | 227 // Immediately stop sending messages to the host. |
| 232 frontend_ = nullptr; | 228 host_ = nullptr; |
| 233 | 229 |
| 234 registrar_->RequestWorkerStopOnUIThread(); | 230 registrar_->RequestWorkerStopOnUIThread(); |
| 235 | 231 |
| 236 core_->ShutdownOnUIThread(); | 232 core_->ShutdownOnUIThread(); |
| 237 } | 233 } |
| 238 | 234 |
| 239 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) { | 235 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) { |
| 240 // StopSyncingForShutdown() (which nulls out |frontend_|) should be | 236 // StopSyncingForShutdown() (which nulls out |host_|) should be |
| 241 // called first. | 237 // called first. |
| 242 DCHECK(!frontend_); | 238 DCHECK(!host_); |
| 243 | 239 |
| 244 if (invalidation_handler_registered_) { | 240 if (invalidation_handler_registered_) { |
| 245 if (reason == DISABLE_SYNC) { | 241 if (reason == DISABLE_SYNC) { |
| 246 UnregisterInvalidationIds(); | 242 UnregisterInvalidationIds(); |
| 247 } | 243 } |
| 248 invalidator_->UnregisterInvalidationHandler(this); | 244 invalidator_->UnregisterInvalidationHandler(this); |
| 249 invalidator_ = nullptr; | 245 invalidator_ = nullptr; |
| 250 } | 246 } |
| 251 invalidation_handler_registered_ = false; | 247 invalidation_handler_registered_ = false; |
| 252 | 248 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 } | 530 } |
| 535 | 531 |
| 536 if (!ready_task.is_null()) | 532 if (!ready_task.is_null()) |
| 537 ready_task.Run(succeeded_configuration_types, failed_configuration_types); | 533 ready_task.Run(succeeded_configuration_types, failed_configuration_types); |
| 538 } | 534 } |
| 539 | 535 |
| 540 void SyncBackendHostImpl::AddExperimentalTypes() { | 536 void SyncBackendHostImpl::AddExperimentalTypes() { |
| 541 CHECK(initialized()); | 537 CHECK(initialized()); |
| 542 Experiments experiments; | 538 Experiments experiments; |
| 543 if (core_->sync_manager()->ReceivedExperiment(&experiments)) | 539 if (core_->sync_manager()->ReceivedExperiment(&experiments)) |
| 544 frontend_->OnExperimentsChanged(experiments); | 540 host_->OnExperimentsChanged(experiments); |
| 545 } | 541 } |
| 546 | 542 |
| 547 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( | 543 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( |
| 548 const WeakHandle<JsBackend> js_backend, | 544 const WeakHandle<JsBackend> js_backend, |
| 549 const WeakHandle<DataTypeDebugInfoListener> debug_info_listener, | 545 const WeakHandle<DataTypeDebugInfoListener> debug_info_listener, |
| 550 std::unique_ptr<ModelTypeConnector> model_type_connector, | 546 std::unique_ptr<ModelTypeConnector> model_type_connector, |
| 551 const std::string& cache_guid) { | 547 const std::string& cache_guid) { |
| 552 DCHECK(thread_checker_.CalledOnValidThread()); | 548 DCHECK(thread_checker_.CalledOnValidThread()); |
| 553 | 549 |
| 554 model_type_connector_ = std::move(model_type_connector); | 550 model_type_connector_ = std::move(model_type_connector); |
| 555 | 551 |
| 556 initialized_ = true; | 552 initialized_ = true; |
| 557 | 553 |
| 558 if (invalidator_) { | 554 if (invalidator_) { |
| 559 invalidator_->RegisterInvalidationHandler(this); | 555 invalidator_->RegisterInvalidationHandler(this); |
| 560 invalidation_handler_registered_ = true; | 556 invalidation_handler_registered_ = true; |
| 561 | 557 |
| 562 // Fake a state change to initialize the SyncManager's cached invalidator | 558 // Fake a state change to initialize the SyncManager's cached invalidator |
| 563 // state. | 559 // state. |
| 564 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); | 560 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); |
| 565 } | 561 } |
| 566 | 562 |
| 567 // Now that we've downloaded the control types, we can see if there are any | 563 // Now that we've downloaded the control types, we can see if there are any |
| 568 // experimental types to enable. This should be done before we inform | 564 // experimental types to enable. This should be done before we inform |
| 569 // the frontend to ensure they're visible in the customize screen. | 565 // the host to ensure they're visible in the customize screen. |
| 570 AddExperimentalTypes(); | 566 AddExperimentalTypes(); |
| 571 frontend_->OnBackendInitialized(js_backend, debug_info_listener, cache_guid, | 567 host_->OnBackendInitialized(js_backend, debug_info_listener, cache_guid, |
| 572 true); | 568 true); |
| 573 } | 569 } |
| 574 | 570 |
| 575 void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() { | 571 void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() { |
| 576 DCHECK(thread_checker_.CalledOnValidThread()); | 572 DCHECK(thread_checker_.CalledOnValidThread()); |
| 577 frontend_->OnBackendInitialized(WeakHandle<JsBackend>(), | 573 host_->OnBackendInitialized(WeakHandle<JsBackend>(), |
| 578 WeakHandle<DataTypeDebugInfoListener>(), "", | 574 WeakHandle<DataTypeDebugInfoListener>(), "", |
| 579 false); | 575 false); |
| 580 } | 576 } |
| 581 | 577 |
| 582 void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop( | 578 void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop( |
| 583 const SyncCycleSnapshot& snapshot) { | 579 const SyncCycleSnapshot& snapshot) { |
| 584 DCHECK(thread_checker_.CalledOnValidThread()); | 580 DCHECK(thread_checker_.CalledOnValidThread()); |
| 585 | 581 |
| 586 last_snapshot_ = snapshot; | 582 last_snapshot_ = snapshot; |
| 587 | 583 |
| 588 SDVLOG(1) << "Got snapshot " << snapshot.ToString(); | 584 SDVLOG(1) << "Got snapshot " << snapshot.ToString(); |
| 589 | 585 |
| 590 if (!snapshot.poll_finish_time().is_null()) | 586 if (!snapshot.poll_finish_time().is_null()) |
| 591 sync_prefs_->SetLastPollTime(snapshot.poll_finish_time()); | 587 sync_prefs_->SetLastPollTime(snapshot.poll_finish_time()); |
| 592 | 588 |
| 593 // Process any changes to the datatypes we're syncing. | 589 // Process any changes to the datatypes we're syncing. |
| 594 // TODO(sync): add support for removing types. | 590 // TODO(sync): add support for removing types. |
| 595 if (initialized()) | 591 if (initialized()) |
| 596 AddExperimentalTypes(); | 592 AddExperimentalTypes(); |
| 597 | 593 |
| 598 if (initialized()) | 594 if (initialized()) |
| 599 frontend_->OnSyncCycleCompleted(); | 595 host_->OnSyncCycleCompleted(); |
| 600 } | 596 } |
| 601 | 597 |
| 602 void SyncBackendHostImpl::RetryConfigurationOnFrontendLoop( | 598 void SyncBackendHostImpl::RetryConfigurationOnFrontendLoop( |
| 603 const base::Closure& retry_callback) { | 599 const base::Closure& retry_callback) { |
| 604 SDVLOG(1) << "Failed to complete configuration, informing of retry."; | 600 SDVLOG(1) << "Failed to complete configuration, informing of retry."; |
| 605 retry_callback.Run(); | 601 retry_callback.Run(); |
| 606 } | 602 } |
| 607 | 603 |
| 608 void SyncBackendHostImpl::PersistEncryptionBootstrapToken( | 604 void SyncBackendHostImpl::PersistEncryptionBootstrapToken( |
| 609 const std::string& token, | 605 const std::string& token, |
| 610 BootstrapTokenType token_type) { | 606 BootstrapTokenType token_type) { |
| 611 CHECK(sync_prefs_.get()); | 607 CHECK(sync_prefs_.get()); |
| 612 if (token_type == PASSPHRASE_BOOTSTRAP_TOKEN) | 608 if (token_type == PASSPHRASE_BOOTSTRAP_TOKEN) |
| 613 sync_prefs_->SetEncryptionBootstrapToken(token); | 609 sync_prefs_->SetEncryptionBootstrapToken(token); |
| 614 else | 610 else |
| 615 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); | 611 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); |
| 616 } | 612 } |
| 617 | 613 |
| 618 void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop( | 614 void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop( |
| 619 const SyncProtocolError& sync_error) { | 615 const SyncProtocolError& sync_error) { |
| 620 DCHECK(thread_checker_.CalledOnValidThread()); | 616 DCHECK(thread_checker_.CalledOnValidThread()); |
| 621 frontend_->OnActionableError(sync_error); | 617 host_->OnActionableError(sync_error); |
| 622 } | 618 } |
| 623 | 619 |
| 624 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( | 620 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( |
| 625 ModelTypeSet types) { | 621 ModelTypeSet types) { |
| 626 DCHECK(thread_checker_.CalledOnValidThread()); | 622 DCHECK(thread_checker_.CalledOnValidThread()); |
| 627 frontend_->OnMigrationNeededForTypes(types); | 623 host_->OnMigrationNeededForTypes(types); |
| 628 } | 624 } |
| 629 | 625 |
| 630 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { | 626 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { |
| 631 sync_task_runner_->PostTask( | 627 sync_task_runner_->PostTask( |
| 632 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, | 628 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, |
| 633 core_, state)); | 629 core_, state)); |
| 634 } | 630 } |
| 635 | 631 |
| 636 void SyncBackendHostImpl::OnIncomingInvalidation( | 632 void SyncBackendHostImpl::OnIncomingInvalidation( |
| 637 const ObjectIdInvalidationMap& invalidation_map) { | 633 const ObjectIdInvalidationMap& invalidation_map) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 657 } | 653 } |
| 658 | 654 |
| 659 void SyncBackendHostImpl::NotifyPassphraseRequired( | 655 void SyncBackendHostImpl::NotifyPassphraseRequired( |
| 660 PassphraseRequiredReason reason, | 656 PassphraseRequiredReason reason, |
| 661 sync_pb::EncryptedData pending_keys) { | 657 sync_pb::EncryptedData pending_keys) { |
| 662 DCHECK(thread_checker_.CalledOnValidThread()); | 658 DCHECK(thread_checker_.CalledOnValidThread()); |
| 663 | 659 |
| 664 // Update our cache of the cryptographer's pending keys. | 660 // Update our cache of the cryptographer's pending keys. |
| 665 cached_pending_keys_ = pending_keys; | 661 cached_pending_keys_ = pending_keys; |
| 666 | 662 |
| 667 frontend_->OnPassphraseRequired(reason, pending_keys); | 663 host_->OnPassphraseRequired(reason, pending_keys); |
| 668 } | 664 } |
| 669 | 665 |
| 670 void SyncBackendHostImpl::NotifyPassphraseAccepted() { | 666 void SyncBackendHostImpl::NotifyPassphraseAccepted() { |
| 671 DCHECK(thread_checker_.CalledOnValidThread()); | 667 DCHECK(thread_checker_.CalledOnValidThread()); |
| 672 // Clear our cache of the cryptographer's pending keys. | 668 // Clear our cache of the cryptographer's pending keys. |
| 673 cached_pending_keys_.clear_blob(); | 669 cached_pending_keys_.clear_blob(); |
| 674 frontend_->OnPassphraseAccepted(); | 670 host_->OnPassphraseAccepted(); |
| 675 } | 671 } |
| 676 | 672 |
| 677 void SyncBackendHostImpl::NotifyEncryptedTypesChanged( | 673 void SyncBackendHostImpl::NotifyEncryptedTypesChanged( |
| 678 ModelTypeSet encrypted_types, | 674 ModelTypeSet encrypted_types, |
| 679 bool encrypt_everything) { | 675 bool encrypt_everything) { |
| 680 DCHECK(thread_checker_.CalledOnValidThread()); | 676 DCHECK(thread_checker_.CalledOnValidThread()); |
| 681 frontend_->OnEncryptedTypesChanged(encrypted_types, encrypt_everything); | 677 host_->OnEncryptedTypesChanged(encrypted_types, encrypt_everything); |
| 682 } | 678 } |
| 683 | 679 |
| 684 void SyncBackendHostImpl::NotifyEncryptionComplete() { | 680 void SyncBackendHostImpl::NotifyEncryptionComplete() { |
| 685 DCHECK(thread_checker_.CalledOnValidThread()); | 681 DCHECK(thread_checker_.CalledOnValidThread()); |
| 686 frontend_->OnEncryptionComplete(); | 682 host_->OnEncryptionComplete(); |
| 687 } | 683 } |
| 688 | 684 |
| 689 void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop( | 685 void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop( |
| 690 PassphraseType type, | 686 PassphraseType type, |
| 691 base::Time explicit_passphrase_time) { | 687 base::Time explicit_passphrase_time) { |
| 692 DCHECK(thread_checker_.CalledOnValidThread()); | 688 DCHECK(thread_checker_.CalledOnValidThread()); |
| 693 DVLOG(1) << "Passphrase type changed to " << PassphraseTypeToString(type); | 689 DVLOG(1) << "Passphrase type changed to " << PassphraseTypeToString(type); |
| 694 cached_passphrase_type_ = type; | 690 cached_passphrase_type_ = type; |
| 695 cached_explicit_passphrase_time_ = explicit_passphrase_time; | 691 cached_explicit_passphrase_time_ = explicit_passphrase_time; |
| 696 } | 692 } |
| 697 | 693 |
| 698 void SyncBackendHostImpl::HandleLocalSetPassphraseEncryptionOnFrontendLoop( | 694 void SyncBackendHostImpl::HandleLocalSetPassphraseEncryptionOnFrontendLoop( |
| 699 const SyncEncryptionHandler::NigoriState& nigori_state) { | 695 const SyncEncryptionHandler::NigoriState& nigori_state) { |
| 700 DCHECK(thread_checker_.CalledOnValidThread()); | 696 DCHECK(thread_checker_.CalledOnValidThread()); |
| 701 frontend_->OnLocalSetPassphraseEncryption(nigori_state); | 697 host_->OnLocalSetPassphraseEncryption(nigori_state); |
| 702 } | 698 } |
| 703 | 699 |
| 704 void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop( | 700 void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop( |
| 705 ConnectionStatus status) { | 701 ConnectionStatus status) { |
| 706 DCHECK(thread_checker_.CalledOnValidThread()); | 702 DCHECK(thread_checker_.CalledOnValidThread()); |
| 707 | |
| 708 DVLOG(1) << "Connection status changed: " << ConnectionStatusToString(status); | 703 DVLOG(1) << "Connection status changed: " << ConnectionStatusToString(status); |
| 709 frontend_->OnConnectionStatusChange(status); | 704 host_->OnConnectionStatusChange(status); |
| 710 } | 705 } |
| 711 | 706 |
| 712 void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop( | 707 void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop( |
| 713 std::unique_ptr<ProtocolEvent> event) { | 708 std::unique_ptr<ProtocolEvent> event) { |
| 714 frontend_->OnProtocolEvent(*event); | 709 DCHECK(thread_checker_.CalledOnValidThread()); |
| 710 host_->OnProtocolEvent(*event); | |
| 715 } | 711 } |
| 716 | 712 |
| 717 void SyncBackendHostImpl::HandleDirectoryCommitCountersUpdatedOnFrontendLoop( | 713 void SyncBackendHostImpl::HandleDirectoryCommitCountersUpdatedOnFrontendLoop( |
| 718 ModelType type, | 714 ModelType type, |
| 719 const CommitCounters& counters) { | 715 const CommitCounters& counters) { |
| 720 frontend_->OnDirectoryTypeCommitCounterUpdated(type, counters); | 716 DCHECK(thread_checker_.CalledOnValidThread()); |
| 717 host_->OnDirectoryTypeCommitCounterUpdated(type, counters); | |
| 721 } | 718 } |
| 722 | 719 |
| 723 void SyncBackendHostImpl::HandleDirectoryUpdateCountersUpdatedOnFrontendLoop( | 720 void SyncBackendHostImpl::HandleDirectoryUpdateCountersUpdatedOnFrontendLoop( |
| 724 ModelType type, | 721 ModelType type, |
| 725 const UpdateCounters& counters) { | 722 const UpdateCounters& counters) { |
| 726 frontend_->OnDirectoryTypeUpdateCounterUpdated(type, counters); | 723 DCHECK(thread_checker_.CalledOnValidThread()); |
| 724 host_->OnDirectoryTypeUpdateCounterUpdated(type, counters); | |
| 727 } | 725 } |
| 728 | 726 |
| 729 void SyncBackendHostImpl::HandleDirectoryStatusCountersUpdatedOnFrontendLoop( | 727 void SyncBackendHostImpl::HandleDirectoryStatusCountersUpdatedOnFrontendLoop( |
| 730 ModelType type, | 728 ModelType type, |
| 731 const StatusCounters& counters) { | 729 const StatusCounters& counters) { |
| 732 frontend_->OnDatatypeStatusCounterUpdated(type, counters); | 730 DCHECK(thread_checker_.CalledOnValidThread()); |
| 731 host_->OnDatatypeStatusCounterUpdated(type, counters); | |
| 733 } | 732 } |
| 734 | 733 |
| 735 void SyncBackendHostImpl::UpdateInvalidationVersions( | 734 void SyncBackendHostImpl::UpdateInvalidationVersions( |
| 736 const std::map<ModelType, int64_t>& invalidation_versions) { | 735 const std::map<ModelType, int64_t>& invalidation_versions) { |
| 736 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 737 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); | 737 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); |
| 738 } | 738 } |
| 739 | 739 |
| 740 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { | 740 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { |
| 741 DCHECK(thread_checker_.CalledOnValidThread()); | 741 DCHECK(thread_checker_.CalledOnValidThread()); |
| 742 sync_task_runner_->PostTask( | 742 sync_task_runner_->PostTask( |
| 743 FROM_HERE, | 743 FROM_HERE, |
| 744 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); | 744 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); |
| 745 } | 745 } |
| 746 | 746 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 764 const SyncManager::ClearServerDataCallback& frontend_callback) { | 764 const SyncManager::ClearServerDataCallback& frontend_callback) { |
| 765 DCHECK(thread_checker_.CalledOnValidThread()); | 765 DCHECK(thread_checker_.CalledOnValidThread()); |
| 766 frontend_callback.Run(); | 766 frontend_callback.Run(); |
| 767 } | 767 } |
| 768 | 768 |
| 769 } // namespace syncer | 769 } // namespace syncer |
| 770 | 770 |
| 771 #undef SDVLOG | 771 #undef SDVLOG |
| 772 | 772 |
| 773 #undef SLOG | 773 #undef SLOG |
| OLD | NEW |