| 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_core.h" | 5 #include "components/sync/driver/glue/sync_backend_host_core.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 restored_keystore_key_for_bootstrapping( | 95 restored_keystore_key_for_bootstrapping( |
| 96 restored_keystore_key_for_bootstrapping), | 96 restored_keystore_key_for_bootstrapping), |
| 97 engine_components_factory(std::move(engine_components_factory)), | 97 engine_components_factory(std::move(engine_components_factory)), |
| 98 unrecoverable_error_handler(unrecoverable_error_handler), | 98 unrecoverable_error_handler(unrecoverable_error_handler), |
| 99 report_unrecoverable_error_function(report_unrecoverable_error_function), | 99 report_unrecoverable_error_function(report_unrecoverable_error_function), |
| 100 saved_nigori_state(std::move(saved_nigori_state)), | 100 saved_nigori_state(std::move(saved_nigori_state)), |
| 101 invalidation_versions(invalidation_versions) {} | 101 invalidation_versions(invalidation_versions) {} |
| 102 | 102 |
| 103 DoInitializeOptions::~DoInitializeOptions() {} | 103 DoInitializeOptions::~DoInitializeOptions() {} |
| 104 | 104 |
| 105 DoConfigureSyncerTypes::DoConfigureSyncerTypes() {} | |
| 106 | |
| 107 DoConfigureSyncerTypes::DoConfigureSyncerTypes( | |
| 108 const DoConfigureSyncerTypes& other) = default; | |
| 109 | |
| 110 DoConfigureSyncerTypes::~DoConfigureSyncerTypes() {} | |
| 111 | |
| 112 SyncBackendHostCore::SyncBackendHostCore( | 105 SyncBackendHostCore::SyncBackendHostCore( |
| 113 const std::string& name, | 106 const std::string& name, |
| 114 const base::FilePath& sync_data_folder_path, | 107 const base::FilePath& sync_data_folder_path, |
| 115 const base::WeakPtr<SyncBackendHostImpl>& backend) | 108 const base::WeakPtr<SyncBackendHostImpl>& backend) |
| 116 : name_(name), | 109 : name_(name), |
| 117 sync_data_folder_path_(sync_data_folder_path), | 110 sync_data_folder_path_(sync_data_folder_path), |
| 118 host_(backend), | 111 host_(backend), |
| 119 weak_ptr_factory_(this) { | 112 weak_ptr_factory_(this) { |
| 120 DCHECK(backend.get()); | 113 DCHECK(backend.get()); |
| 121 // This is constructed on the UI thread but used from the sync thread. | 114 // This is constructed on the UI thread but used from the sync thread. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 ModelTypeSet new_control_types = | 188 ModelTypeSet new_control_types = |
| 196 registrar_->ConfigureDataTypes(ControlTypes(), ModelTypeSet()); | 189 registrar_->ConfigureDataTypes(ControlTypes(), ModelTypeSet()); |
| 197 ModelSafeRoutingInfo routing_info; | 190 ModelSafeRoutingInfo routing_info; |
| 198 registrar_->GetModelSafeRoutingInfo(&routing_info); | 191 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 199 SDVLOG(1) << "Control Types " << ModelTypeSetToString(new_control_types) | 192 SDVLOG(1) << "Control Types " << ModelTypeSetToString(new_control_types) |
| 200 << " added; calling ConfigureSyncer"; | 193 << " added; calling ConfigureSyncer"; |
| 201 | 194 |
| 202 ModelTypeSet types_to_purge = | 195 ModelTypeSet types_to_purge = |
| 203 Difference(ModelTypeSet::All(), GetRoutingInfoTypes(routing_info)); | 196 Difference(ModelTypeSet::All(), GetRoutingInfoTypes(routing_info)); |
| 204 | 197 |
| 198 sync_manager_->PurgeDisabledTypes(types_to_purge, ModelTypeSet(), |
| 199 ModelTypeSet()); |
| 205 sync_manager_->ConfigureSyncer( | 200 sync_manager_->ConfigureSyncer( |
| 206 reason, new_control_types, types_to_purge, ModelTypeSet(), ModelTypeSet(), | 201 reason, new_control_types, routing_info, |
| 207 routing_info, | |
| 208 base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes, | 202 base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes, |
| 209 weak_ptr_factory_.GetWeakPtr()), | 203 weak_ptr_factory_.GetWeakPtr()), |
| 210 base::Closure()); | 204 base::Closure()); |
| 211 } | 205 } |
| 212 | 206 |
| 213 void SyncBackendHostCore::OnConnectionStatusChange(ConnectionStatus status) { | 207 void SyncBackendHostCore::OnConnectionStatusChange(ConnectionStatus status) { |
| 214 DCHECK(thread_checker_.CalledOnValidThread()); | 208 DCHECK(thread_checker_.CalledOnValidThread()); |
| 215 host_.Call(FROM_HERE, | 209 host_.Call(FROM_HERE, |
| 216 &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop, | 210 &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop, |
| 217 status); | 211 status); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 this); | 541 this); |
| 548 if (sync_manager_) { | 542 if (sync_manager_) { |
| 549 DisableDirectoryTypeDebugInfoForwarding(); | 543 DisableDirectoryTypeDebugInfoForwarding(); |
| 550 save_changes_timer_.reset(); | 544 save_changes_timer_.reset(); |
| 551 sync_manager_->RemoveObserver(this); | 545 sync_manager_->RemoveObserver(this); |
| 552 sync_manager_->ShutdownOnSyncThread(reason); | 546 sync_manager_->ShutdownOnSyncThread(reason); |
| 553 sync_manager_.reset(); | 547 sync_manager_.reset(); |
| 554 } | 548 } |
| 555 } | 549 } |
| 556 | 550 |
| 551 void SyncBackendHostCore::DoPurgeDisabledTypes(const ModelTypeSet& to_purge, |
| 552 const ModelTypeSet& to_journal, |
| 553 const ModelTypeSet& to_unapply) { |
| 554 DCHECK(thread_checker_.CalledOnValidThread()); |
| 555 sync_manager_->PurgeDisabledTypes(to_purge, to_journal, to_unapply); |
| 556 } |
| 557 |
| 557 void SyncBackendHostCore::DoConfigureSyncer( | 558 void SyncBackendHostCore::DoConfigureSyncer( |
| 558 ConfigureReason reason, | 559 ConfigureReason reason, |
| 559 const DoConfigureSyncerTypes& config_types, | 560 const ModelTypeSet& to_download, |
| 560 const ModelSafeRoutingInfo routing_info, | 561 const ModelSafeRoutingInfo routing_info, |
| 561 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, | 562 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, |
| 562 const base::Closure& retry_callback) { | 563 const base::Closure& retry_callback) { |
| 563 DCHECK(thread_checker_.CalledOnValidThread()); | 564 DCHECK(thread_checker_.CalledOnValidThread()); |
| 564 DCHECK(!ready_task.is_null()); | 565 DCHECK(!ready_task.is_null()); |
| 565 DCHECK(!retry_callback.is_null()); | 566 DCHECK(!retry_callback.is_null()); |
| 566 base::Closure chained_ready_task(base::Bind( | 567 base::Closure chained_ready_task( |
| 567 &SyncBackendHostCore::DoFinishConfigureDataTypes, | 568 base::Bind(&SyncBackendHostCore::DoFinishConfigureDataTypes, |
| 568 weak_ptr_factory_.GetWeakPtr(), config_types.to_download, ready_task)); | 569 weak_ptr_factory_.GetWeakPtr(), to_download, ready_task)); |
| 569 base::Closure chained_retry_task( | 570 base::Closure chained_retry_task( |
| 570 base::Bind(&SyncBackendHostCore::DoRetryConfiguration, | 571 base::Bind(&SyncBackendHostCore::DoRetryConfiguration, |
| 571 weak_ptr_factory_.GetWeakPtr(), retry_callback)); | 572 weak_ptr_factory_.GetWeakPtr(), retry_callback)); |
| 572 sync_manager_->ConfigureSyncer(reason, config_types.to_download, | 573 sync_manager_->ConfigureSyncer(reason, to_download, routing_info, |
| 573 config_types.to_purge, config_types.to_journal, | |
| 574 config_types.to_unapply, routing_info, | |
| 575 chained_ready_task, chained_retry_task); | 574 chained_ready_task, chained_retry_task); |
| 576 } | 575 } |
| 577 | 576 |
| 578 void SyncBackendHostCore::DoFinishConfigureDataTypes( | 577 void SyncBackendHostCore::DoFinishConfigureDataTypes( |
| 579 ModelTypeSet types_to_config, | 578 ModelTypeSet types_to_config, |
| 580 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { | 579 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { |
| 581 DCHECK(thread_checker_.CalledOnValidThread()); | 580 DCHECK(thread_checker_.CalledOnValidThread()); |
| 582 | 581 |
| 583 // Update the enabled types for the bridge and sync manager. | 582 // Update the enabled types for the bridge and sync manager. |
| 584 ModelSafeRoutingInfo routing_info; | 583 ModelSafeRoutingInfo routing_info; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 } | 688 } |
| 690 | 689 |
| 691 void SyncBackendHostCore::ClearServerDataDone( | 690 void SyncBackendHostCore::ClearServerDataDone( |
| 692 const base::Closure& frontend_callback) { | 691 const base::Closure& frontend_callback) { |
| 693 DCHECK(thread_checker_.CalledOnValidThread()); | 692 DCHECK(thread_checker_.CalledOnValidThread()); |
| 694 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, | 693 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, |
| 695 frontend_callback); | 694 frontend_callback); |
| 696 } | 695 } |
| 697 | 696 |
| 698 } // namespace syncer | 697 } // namespace syncer |
| OLD | NEW |