| 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 <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/single_thread_task_runner.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_driver/glue/sync_backend_host_core.h" | 19 #include "components/sync_driver/glue/sync_backend_host_core.h" |
| 20 #include "components/sync_driver/glue/sync_backend_registrar.h" | 20 #include "components/sync_driver/glue/sync_backend_registrar.h" |
| 21 #include "components/sync_driver/invalidation_helper.h" | 21 #include "components/sync_driver/invalidation_helper.h" |
| 22 #include "components/sync_driver/sync_client.h" | 22 #include "components/sync_driver/sync_client.h" |
| 23 #include "components/sync_driver/sync_driver_switches.h" | 23 #include "components/sync_driver/sync_driver_switches.h" |
| 24 #include "components/sync_driver/sync_frontend.h" | 24 #include "components/sync_driver/sync_frontend.h" |
| 25 #include "components/sync_driver/sync_prefs.h" | 25 #include "components/sync_driver/sync_prefs.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 namespace browser_sync { | 46 namespace browser_sync { |
| 47 | 47 |
| 48 SyncBackendHostImpl::SyncBackendHostImpl( | 48 SyncBackendHostImpl::SyncBackendHostImpl( |
| 49 const std::string& name, | 49 const std::string& name, |
| 50 sync_driver::SyncClient* sync_client, | 50 sync_driver::SyncClient* sync_client, |
| 51 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 51 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 52 invalidation::InvalidationService* invalidator, | 52 invalidation::InvalidationService* invalidator, |
| 53 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 53 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
| 54 const base::FilePath& sync_folder) | 54 const base::FilePath& sync_folder) |
| 55 : frontend_loop_(base::MessageLoop::current()), | 55 : frontend_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 56 sync_client_(sync_client), | 56 sync_client_(sync_client), |
| 57 ui_thread_(ui_thread), | 57 ui_thread_(ui_thread), |
| 58 name_(name), | 58 name_(name), |
| 59 initialized_(false), | 59 initialized_(false), |
| 60 sync_prefs_(sync_prefs), | 60 sync_prefs_(sync_prefs), |
| 61 frontend_(NULL), | 61 frontend_(NULL), |
| 62 cached_passphrase_type_(syncer::IMPLICIT_PASSPHRASE), | 62 cached_passphrase_type_(syncer::IMPLICIT_PASSPHRASE), |
| 63 invalidator_(invalidator), | 63 invalidator_(invalidator), |
| 64 invalidation_handler_registered_(false), | 64 invalidation_handler_registered_(false), |
| 65 weak_ptr_factory_(this) { | 65 weak_ptr_factory_(this) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 if (!IsNigoriEnabled()) { | 167 if (!IsNigoriEnabled()) { |
| 168 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" | 168 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" |
| 169 " is disabled."; | 169 " is disabled."; |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 | 172 |
| 173 // We should never be called with an empty passphrase. | 173 // We should never be called with an empty passphrase. |
| 174 DCHECK(!passphrase.empty()); | 174 DCHECK(!passphrase.empty()); |
| 175 | 175 |
| 176 // This should only be called by the frontend. | 176 // This should only be called by the frontend. |
| 177 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 177 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 178 | 178 |
| 179 // SetEncryptionPassphrase should never be called if we are currently | 179 // SetEncryptionPassphrase should never be called if we are currently |
| 180 // encrypted with an explicit passphrase. | 180 // encrypted with an explicit passphrase. |
| 181 DCHECK(cached_passphrase_type_ == syncer::KEYSTORE_PASSPHRASE || | 181 DCHECK(cached_passphrase_type_ == syncer::KEYSTORE_PASSPHRASE || |
| 182 cached_passphrase_type_ == syncer::IMPLICIT_PASSPHRASE); | 182 cached_passphrase_type_ == syncer::IMPLICIT_PASSPHRASE); |
| 183 | 183 |
| 184 // Post an encryption task on the syncer thread. | 184 // Post an encryption task on the syncer thread. |
| 185 registrar_->sync_thread()->task_runner()->PostTask( | 185 registrar_->sync_thread()->task_runner()->PostTask( |
| 186 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, | 186 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, |
| 187 core_.get(), passphrase, is_explicit)); | 187 core_.get(), passphrase, is_explicit)); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool SyncBackendHostImpl::SetDecryptionPassphrase( | 190 bool SyncBackendHostImpl::SetDecryptionPassphrase( |
| 191 const std::string& passphrase) { | 191 const std::string& passphrase) { |
| 192 if (!IsNigoriEnabled()) { | 192 if (!IsNigoriEnabled()) { |
| 193 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" | 193 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" |
| 194 " is disabled."; | 194 " is disabled."; |
| 195 return false; | 195 return false; |
| 196 } | 196 } |
| 197 | 197 |
| 198 // We should never be called with an empty passphrase. | 198 // We should never be called with an empty passphrase. |
| 199 DCHECK(!passphrase.empty()); | 199 DCHECK(!passphrase.empty()); |
| 200 | 200 |
| 201 // This should only be called by the frontend. | 201 // This should only be called by the frontend. |
| 202 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 202 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 203 | 203 |
| 204 // This should only be called when we have cached pending keys. | 204 // This should only be called when we have cached pending keys. |
| 205 DCHECK(cached_pending_keys_.has_blob()); | 205 DCHECK(cached_pending_keys_.has_blob()); |
| 206 | 206 |
| 207 // Check the passphrase that was provided against our local cache of the | 207 // Check the passphrase that was provided against our local cache of the |
| 208 // cryptographer's pending keys. If this was unsuccessful, the UI layer can | 208 // cryptographer's pending keys. If this was unsuccessful, the UI layer can |
| 209 // immediately call OnPassphraseRequired without showing the user a spinner. | 209 // immediately call OnPassphraseRequired without showing the user a spinner. |
| 210 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) | 210 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) |
| 211 return false; | 211 return false; |
| 212 | 212 |
| 213 // Post a decryption task on the syncer thread. | 213 // Post a decryption task on the syncer thread. |
| 214 registrar_->sync_thread()->task_runner()->PostTask( | 214 registrar_->sync_thread()->task_runner()->PostTask( |
| 215 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, | 215 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, |
| 216 core_.get(), passphrase)); | 216 core_.get(), passphrase)); |
| 217 | 217 |
| 218 // Since we were able to decrypt the cached pending keys with the passphrase | 218 // Since we were able to decrypt the cached pending keys with the passphrase |
| 219 // provided, we immediately alert the UI layer that the passphrase was | 219 // provided, we immediately alert the UI layer that the passphrase was |
| 220 // accepted. This will avoid the situation where a user enters a passphrase, | 220 // accepted. This will avoid the situation where a user enters a passphrase, |
| 221 // clicks OK, immediately reopens the advanced settings dialog, and gets an | 221 // clicks OK, immediately reopens the advanced settings dialog, and gets an |
| 222 // unnecessary prompt for a passphrase. | 222 // unnecessary prompt for a passphrase. |
| 223 // Note: It is not guaranteed that the passphrase will be accepted by the | 223 // Note: It is not guaranteed that the passphrase will be accepted by the |
| 224 // syncer thread, since we could receive a new nigori node while the task is | 224 // syncer thread, since we could receive a new nigori node while the task is |
| 225 // pending. This scenario is a valid race, and SetDecryptionPassphrase can | 225 // pending. This scenario is a valid race, and SetDecryptionPassphrase can |
| 226 // trigger a new OnPassphraseRequired if it needs to. | 226 // trigger a new OnPassphraseRequired if it needs to. |
| 227 NotifyPassphraseAccepted(); | 227 NotifyPassphraseAccepted(); |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void SyncBackendHostImpl::StopSyncingForShutdown() { | 231 void SyncBackendHostImpl::StopSyncingForShutdown() { |
| 232 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 232 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 233 | 233 |
| 234 // Immediately stop sending messages to the frontend. | 234 // Immediately stop sending messages to the frontend. |
| 235 frontend_ = NULL; | 235 frontend_ = NULL; |
| 236 | 236 |
| 237 DCHECK(registrar_->sync_thread()->IsRunning()); | 237 DCHECK(registrar_->sync_thread()->IsRunning()); |
| 238 | 238 |
| 239 registrar_->RequestWorkerStopOnUIThread(); | 239 registrar_->RequestWorkerStopOnUIThread(); |
| 240 | 240 |
| 241 core_->ShutdownOnUIThread(); | 241 core_->ShutdownOnUIThread(); |
| 242 } | 242 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 core_)); | 529 core_)); |
| 530 } | 530 } |
| 531 | 531 |
| 532 void SyncBackendHostImpl::GetAllNodesForTypes( | 532 void SyncBackendHostImpl::GetAllNodesForTypes( |
| 533 syncer::ModelTypeSet types, | 533 syncer::ModelTypeSet types, |
| 534 base::Callback<void(const std::vector<syncer::ModelType>&, | 534 base::Callback<void(const std::vector<syncer::ModelType>&, |
| 535 ScopedVector<base::ListValue>)> callback) { | 535 ScopedVector<base::ListValue>)> callback) { |
| 536 DCHECK(initialized()); | 536 DCHECK(initialized()); |
| 537 registrar_->sync_thread()->task_runner()->PostTask( | 537 registrar_->sync_thread()->task_runner()->PostTask( |
| 538 FROM_HERE, base::Bind(&SyncBackendHostCore::GetAllNodesForTypes, core_, | 538 FROM_HERE, base::Bind(&SyncBackendHostCore::GetAllNodesForTypes, core_, |
| 539 types, frontend_loop_->task_runner(), callback)); | 539 types, frontend_task_runner_, callback)); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void SyncBackendHostImpl::InitCore( | 542 void SyncBackendHostImpl::InitCore( |
| 543 std::unique_ptr<DoInitializeOptions> options) { | 543 std::unique_ptr<DoInitializeOptions> options) { |
| 544 registrar_->sync_thread()->task_runner()->PostTask( | 544 registrar_->sync_thread()->task_runner()->PostTask( |
| 545 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_.get(), | 545 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_.get(), |
| 546 base::Passed(&options))); | 546 base::Passed(&options))); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void SyncBackendHostImpl::RequestConfigureSyncer( | 549 void SyncBackendHostImpl::RequestConfigureSyncer( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 if (core_->sync_manager()->ReceivedExperiment(&experiments)) | 592 if (core_->sync_manager()->ReceivedExperiment(&experiments)) |
| 593 frontend_->OnExperimentsChanged(experiments); | 593 frontend_->OnExperimentsChanged(experiments); |
| 594 } | 594 } |
| 595 | 595 |
| 596 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( | 596 void SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( |
| 597 const syncer::WeakHandle<syncer::JsBackend> js_backend, | 597 const syncer::WeakHandle<syncer::JsBackend> js_backend, |
| 598 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> | 598 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> |
| 599 debug_info_listener, | 599 debug_info_listener, |
| 600 std::unique_ptr<syncer_v2::ModelTypeConnector> model_type_connector, | 600 std::unique_ptr<syncer_v2::ModelTypeConnector> model_type_connector, |
| 601 const std::string& cache_guid) { | 601 const std::string& cache_guid) { |
| 602 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 602 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 603 | 603 |
| 604 model_type_connector_ = std::move(model_type_connector); | 604 model_type_connector_ = std::move(model_type_connector); |
| 605 | 605 |
| 606 if (!frontend_) | 606 if (!frontend_) |
| 607 return; | 607 return; |
| 608 | 608 |
| 609 initialized_ = true; | 609 initialized_ = true; |
| 610 | 610 |
| 611 if (invalidator_) { | 611 if (invalidator_) { |
| 612 invalidator_->RegisterInvalidationHandler(this); | 612 invalidator_->RegisterInvalidationHandler(this); |
| 613 invalidation_handler_registered_ = true; | 613 invalidation_handler_registered_ = true; |
| 614 | 614 |
| 615 // Fake a state change to initialize the SyncManager's cached invalidator | 615 // Fake a state change to initialize the SyncManager's cached invalidator |
| 616 // state. | 616 // state. |
| 617 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); | 617 OnInvalidatorStateChange(invalidator_->GetInvalidatorState()); |
| 618 } | 618 } |
| 619 | 619 |
| 620 // Now that we've downloaded the control types, we can see if there are any | 620 // Now that we've downloaded the control types, we can see if there are any |
| 621 // experimental types to enable. This should be done before we inform | 621 // experimental types to enable. This should be done before we inform |
| 622 // the frontend to ensure they're visible in the customize screen. | 622 // the frontend to ensure they're visible in the customize screen. |
| 623 AddExperimentalTypes(); | 623 AddExperimentalTypes(); |
| 624 frontend_->OnBackendInitialized(js_backend, | 624 frontend_->OnBackendInitialized(js_backend, |
| 625 debug_info_listener, | 625 debug_info_listener, |
| 626 cache_guid, | 626 cache_guid, |
| 627 true); | 627 true); |
| 628 } | 628 } |
| 629 | 629 |
| 630 void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() { | 630 void SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop() { |
| 631 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 631 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 632 if (!frontend_) | 632 if (!frontend_) |
| 633 return; | 633 return; |
| 634 | 634 |
| 635 frontend_->OnBackendInitialized( | 635 frontend_->OnBackendInitialized( |
| 636 syncer::WeakHandle<syncer::JsBackend>(), | 636 syncer::WeakHandle<syncer::JsBackend>(), |
| 637 syncer::WeakHandle<syncer::DataTypeDebugInfoListener>(), | 637 syncer::WeakHandle<syncer::DataTypeDebugInfoListener>(), |
| 638 "", | 638 "", |
| 639 false); | 639 false); |
| 640 } | 640 } |
| 641 | 641 |
| 642 void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop( | 642 void SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop( |
| 643 const syncer::sessions::SyncSessionSnapshot& snapshot) { | 643 const syncer::sessions::SyncSessionSnapshot& snapshot) { |
| 644 if (!frontend_) | 644 if (!frontend_) |
| 645 return; | 645 return; |
| 646 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 646 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 647 | 647 |
| 648 last_snapshot_ = snapshot; | 648 last_snapshot_ = snapshot; |
| 649 | 649 |
| 650 SDVLOG(1) << "Got snapshot " << snapshot.ToString(); | 650 SDVLOG(1) << "Got snapshot " << snapshot.ToString(); |
| 651 | 651 |
| 652 if (!snapshot.poll_finish_time().is_null()) | 652 if (!snapshot.poll_finish_time().is_null()) |
| 653 sync_prefs_->SetLastPollTime(snapshot.poll_finish_time()); | 653 sync_prefs_->SetLastPollTime(snapshot.poll_finish_time()); |
| 654 | 654 |
| 655 // Process any changes to the datatypes we're syncing. | 655 // Process any changes to the datatypes we're syncing. |
| 656 // TODO(sync): add support for removing types. | 656 // TODO(sync): add support for removing types. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 674 if (token_type == syncer::PASSPHRASE_BOOTSTRAP_TOKEN) | 674 if (token_type == syncer::PASSPHRASE_BOOTSTRAP_TOKEN) |
| 675 sync_prefs_->SetEncryptionBootstrapToken(token); | 675 sync_prefs_->SetEncryptionBootstrapToken(token); |
| 676 else | 676 else |
| 677 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); | 677 sync_prefs_->SetKeystoreEncryptionBootstrapToken(token); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop( | 680 void SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop( |
| 681 const syncer::SyncProtocolError& sync_error) { | 681 const syncer::SyncProtocolError& sync_error) { |
| 682 if (!frontend_) | 682 if (!frontend_) |
| 683 return; | 683 return; |
| 684 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 684 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 685 frontend_->OnActionableError(sync_error); | 685 frontend_->OnActionableError(sync_error); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( | 688 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( |
| 689 syncer::ModelTypeSet types) { | 689 syncer::ModelTypeSet types) { |
| 690 if (!frontend_) | 690 if (!frontend_) |
| 691 return; | 691 return; |
| 692 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 692 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 693 frontend_->OnMigrationNeededForTypes(types); | 693 frontend_->OnMigrationNeededForTypes(types); |
| 694 } | 694 } |
| 695 | 695 |
| 696 void SyncBackendHostImpl::OnInvalidatorStateChange( | 696 void SyncBackendHostImpl::OnInvalidatorStateChange( |
| 697 syncer::InvalidatorState state) { | 697 syncer::InvalidatorState state) { |
| 698 registrar_->sync_thread()->task_runner()->PostTask( | 698 registrar_->sync_thread()->task_runner()->PostTask( |
| 699 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, | 699 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, |
| 700 core_.get(), state)); | 700 core_.get(), state)); |
| 701 } | 701 } |
| 702 | 702 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 722 DVLOG_IF(1, result) << "Passphrase failed to decrypt pending keys."; | 722 DVLOG_IF(1, result) << "Passphrase failed to decrypt pending keys."; |
| 723 return result; | 723 return result; |
| 724 } | 724 } |
| 725 | 725 |
| 726 void SyncBackendHostImpl::NotifyPassphraseRequired( | 726 void SyncBackendHostImpl::NotifyPassphraseRequired( |
| 727 syncer::PassphraseRequiredReason reason, | 727 syncer::PassphraseRequiredReason reason, |
| 728 sync_pb::EncryptedData pending_keys) { | 728 sync_pb::EncryptedData pending_keys) { |
| 729 if (!frontend_) | 729 if (!frontend_) |
| 730 return; | 730 return; |
| 731 | 731 |
| 732 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 732 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 733 | 733 |
| 734 // Update our cache of the cryptographer's pending keys. | 734 // Update our cache of the cryptographer's pending keys. |
| 735 cached_pending_keys_ = pending_keys; | 735 cached_pending_keys_ = pending_keys; |
| 736 | 736 |
| 737 frontend_->OnPassphraseRequired(reason, pending_keys); | 737 frontend_->OnPassphraseRequired(reason, pending_keys); |
| 738 } | 738 } |
| 739 | 739 |
| 740 void SyncBackendHostImpl::NotifyPassphraseAccepted() { | 740 void SyncBackendHostImpl::NotifyPassphraseAccepted() { |
| 741 if (!frontend_) | 741 if (!frontend_) |
| 742 return; | 742 return; |
| 743 | 743 |
| 744 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 744 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 745 | 745 |
| 746 // Clear our cache of the cryptographer's pending keys. | 746 // Clear our cache of the cryptographer's pending keys. |
| 747 cached_pending_keys_.clear_blob(); | 747 cached_pending_keys_.clear_blob(); |
| 748 frontend_->OnPassphraseAccepted(); | 748 frontend_->OnPassphraseAccepted(); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void SyncBackendHostImpl::NotifyEncryptedTypesChanged( | 751 void SyncBackendHostImpl::NotifyEncryptedTypesChanged( |
| 752 syncer::ModelTypeSet encrypted_types, | 752 syncer::ModelTypeSet encrypted_types, |
| 753 bool encrypt_everything) { | 753 bool encrypt_everything) { |
| 754 if (!frontend_) | 754 if (!frontend_) |
| 755 return; | 755 return; |
| 756 | 756 |
| 757 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 757 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 758 frontend_->OnEncryptedTypesChanged( | 758 frontend_->OnEncryptedTypesChanged( |
| 759 encrypted_types, encrypt_everything); | 759 encrypted_types, encrypt_everything); |
| 760 } | 760 } |
| 761 | 761 |
| 762 void SyncBackendHostImpl::NotifyEncryptionComplete() { | 762 void SyncBackendHostImpl::NotifyEncryptionComplete() { |
| 763 if (!frontend_) | 763 if (!frontend_) |
| 764 return; | 764 return; |
| 765 | 765 |
| 766 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 766 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 767 frontend_->OnEncryptionComplete(); | 767 frontend_->OnEncryptionComplete(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop( | 770 void SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop( |
| 771 syncer::PassphraseType type, | 771 syncer::PassphraseType type, |
| 772 base::Time explicit_passphrase_time) { | 772 base::Time explicit_passphrase_time) { |
| 773 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 773 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 774 DVLOG(1) << "Passphrase type changed to " | 774 DVLOG(1) << "Passphrase type changed to " |
| 775 << syncer::PassphraseTypeToString(type); | 775 << syncer::PassphraseTypeToString(type); |
| 776 cached_passphrase_type_ = type; | 776 cached_passphrase_type_ = type; |
| 777 cached_explicit_passphrase_time_ = explicit_passphrase_time; | 777 cached_explicit_passphrase_time_ = explicit_passphrase_time; |
| 778 } | 778 } |
| 779 | 779 |
| 780 void SyncBackendHostImpl::HandleLocalSetPassphraseEncryptionOnFrontendLoop( | 780 void SyncBackendHostImpl::HandleLocalSetPassphraseEncryptionOnFrontendLoop( |
| 781 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) { | 781 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) { |
| 782 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 782 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 783 frontend_->OnLocalSetPassphraseEncryption(nigori_state); | 783 frontend_->OnLocalSetPassphraseEncryption(nigori_state); |
| 784 } | 784 } |
| 785 | 785 |
| 786 void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop( | 786 void SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop( |
| 787 syncer::ConnectionStatus status) { | 787 syncer::ConnectionStatus status) { |
| 788 if (!frontend_) | 788 if (!frontend_) |
| 789 return; | 789 return; |
| 790 | 790 |
| 791 DCHECK_EQ(base::MessageLoop::current(), frontend_loop_); | 791 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); |
| 792 | 792 |
| 793 DVLOG(1) << "Connection status changed: " | 793 DVLOG(1) << "Connection status changed: " |
| 794 << syncer::ConnectionStatusToString(status); | 794 << syncer::ConnectionStatusToString(status); |
| 795 frontend_->OnConnectionStatusChange(status); | 795 frontend_->OnConnectionStatusChange(status); |
| 796 } | 796 } |
| 797 | 797 |
| 798 void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop( | 798 void SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop( |
| 799 syncer::ProtocolEvent* event) { | 799 syncer::ProtocolEvent* event) { |
| 800 std::unique_ptr<syncer::ProtocolEvent> scoped_event(event); | 800 std::unique_ptr<syncer::ProtocolEvent> scoped_event(event); |
| 801 if (!frontend_) | 801 if (!frontend_) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) { | 864 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) { |
| 865 DCHECK(ui_thread_->BelongsToCurrentThread()); | 865 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 866 frontend_callback.Run(); | 866 frontend_callback.Run(); |
| 867 } | 867 } |
| 868 | 868 |
| 869 } // namespace browser_sync | 869 } // namespace browser_sync |
| 870 | 870 |
| 871 #undef SDVLOG | 871 #undef SDVLOG |
| 872 | 872 |
| 873 #undef SLOG | 873 #undef SLOG |
| OLD | NEW |