Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: components/sync/driver/glue/sync_backend_host_core.cc

Issue 2641523004: [Sync] Make directory types registration explicit in ModelTypeRegistry (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // which we initialize below to ensure that we don't perform any downloads if 134 // which we initialize below to ensure that we don't perform any downloads if
135 // all control types have already completed their initial sync. 135 // all control types have already completed their initial sync.
136 registrar_->SetInitialTypes(restored_types); 136 registrar_->SetInitialTypes(restored_types);
137 137
138 ConfigureReason reason = restored_types.Empty() 138 ConfigureReason reason = restored_types.Empty()
139 ? CONFIGURE_REASON_NEW_CLIENT 139 ? CONFIGURE_REASON_NEW_CLIENT
140 : CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; 140 : CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
141 141
142 ModelTypeSet new_control_types = 142 ModelTypeSet new_control_types =
143 registrar_->ConfigureDataTypes(ControlTypes(), ModelTypeSet()); 143 registrar_->ConfigureDataTypes(ControlTypes(), ModelTypeSet());
144
145 // Control types don't have DataTypeControllers, but they need to have
146 // update handlers registerd in ModelTypeRegistry. Register them here.
maxbogue 2017/01/18 01:24:11 registered
pavely 2017/01/18 20:18:07 Done.
147 auto model_type_connector = sync_manager_->GetModelTypeConnectorProxy();
maxbogue 2017/01/18 01:24:11 I think you should probably just have an accessor
pavely 2017/01/18 20:18:07 Done.
148 ModelTypeSet control_types = ControlTypes();
149 for (auto it = control_types.First(); it.Good(); it.Inc()) {
150 model_type_connector->RegisterDirectoryType(it.Get(), GROUP_PASSIVE);
151 }
152
144 ModelSafeRoutingInfo routing_info; 153 ModelSafeRoutingInfo routing_info;
145 registrar_->GetModelSafeRoutingInfo(&routing_info); 154 registrar_->GetModelSafeRoutingInfo(&routing_info);
146 SDVLOG(1) << "Control Types " << ModelTypeSetToString(new_control_types) 155 SDVLOG(1) << "Control Types " << ModelTypeSetToString(new_control_types)
147 << " added; calling ConfigureSyncer"; 156 << " added; calling ConfigureSyncer";
148 157
149 ModelTypeSet types_to_purge = 158 ModelTypeSet types_to_purge =
150 Difference(ModelTypeSet::All(), GetRoutingInfoTypes(routing_info)); 159 Difference(ModelTypeSet::All(), GetRoutingInfoTypes(routing_info));
151 160
152 sync_manager_->PurgeDisabledTypes(types_to_purge, ModelTypeSet(), 161 sync_manager_->PurgeDisabledTypes(types_to_purge, ModelTypeSet(),
153 ModelTypeSet()); 162 ModelTypeSet());
154 sync_manager_->ConfigureSyncer( 163 sync_manager_->ConfigureSyncer(
155 reason, new_control_types, routing_info, 164 reason, new_control_types,
156 base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes, 165 base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes,
157 weak_ptr_factory_.GetWeakPtr()), 166 weak_ptr_factory_.GetWeakPtr()),
158 base::Closure()); 167 base::Closure());
159 } 168 }
160 169
161 void SyncBackendHostCore::OnConnectionStatusChange(ConnectionStatus status) { 170 void SyncBackendHostCore::OnConnectionStatusChange(ConnectionStatus status) {
162 DCHECK(thread_checker_.CalledOnValidThread()); 171 DCHECK(thread_checker_.CalledOnValidThread());
163 host_.Call(FROM_HERE, 172 host_.Call(FROM_HERE,
164 &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop, 173 &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop,
165 status); 174 status);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 DCHECK(thread_checker_.CalledOnValidThread()); 391 DCHECK(thread_checker_.CalledOnValidThread());
383 // UpdateCredentials can be called during backend initialization, possibly 392 // UpdateCredentials can be called during backend initialization, possibly
384 // when backend initialization has failed but hasn't notified the UI thread 393 // when backend initialization has failed but hasn't notified the UI thread
385 // yet. In that case, the sync manager may have been destroyed on the sync 394 // yet. In that case, the sync manager may have been destroyed on the sync
386 // thread before this task was executed, so we do nothing. 395 // thread before this task was executed, so we do nothing.
387 if (sync_manager_) { 396 if (sync_manager_) {
388 sync_manager_->UpdateCredentials(credentials); 397 sync_manager_->UpdateCredentials(credentials);
389 } 398 }
390 } 399 }
391 400
392 void SyncBackendHostCore::DoStartSyncing( 401 void SyncBackendHostCore::DoStartConfiguration() {
393 const ModelSafeRoutingInfo& routing_info, 402 sync_manager_->StartConfiguration();
394 base::Time last_poll_time) { 403 }
404
405 void SyncBackendHostCore::DoStartSyncing(base::Time last_poll_time) {
395 DCHECK(thread_checker_.CalledOnValidThread()); 406 DCHECK(thread_checker_.CalledOnValidThread());
396 sync_manager_->StartSyncingNormally(routing_info, last_poll_time); 407 sync_manager_->StartSyncingNormally(last_poll_time);
397 } 408 }
398 409
399 void SyncBackendHostCore::DoSetEncryptionPassphrase( 410 void SyncBackendHostCore::DoSetEncryptionPassphrase(
400 const std::string& passphrase, 411 const std::string& passphrase,
401 bool is_explicit) { 412 bool is_explicit) {
402 DCHECK(thread_checker_.CalledOnValidThread()); 413 DCHECK(thread_checker_.CalledOnValidThread());
403 sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(passphrase, 414 sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(passphrase,
404 is_explicit); 415 is_explicit);
405 } 416 }
406 417
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 519 }
509 520
510 void SyncBackendHostCore::DoConfigureSyncer( 521 void SyncBackendHostCore::DoConfigureSyncer(
511 ModelTypeConfigurer::ConfigureParams params) { 522 ModelTypeConfigurer::ConfigureParams params) {
512 DCHECK(thread_checker_.CalledOnValidThread()); 523 DCHECK(thread_checker_.CalledOnValidThread());
513 DCHECK(!params.ready_task.is_null()); 524 DCHECK(!params.ready_task.is_null());
514 DCHECK(!params.retry_callback.is_null()); 525 DCHECK(!params.retry_callback.is_null());
515 526
516 registrar_->ConfigureDataTypes(params.enabled_types, params.disabled_types); 527 registrar_->ConfigureDataTypes(params.enabled_types, params.disabled_types);
517 528
518 ModelSafeRoutingInfo routing_info;
519 registrar_->GetModelSafeRoutingInfo(&routing_info);
520
521 base::Closure chained_ready_task(base::Bind( 529 base::Closure chained_ready_task(base::Bind(
522 &SyncBackendHostCore::DoFinishConfigureDataTypes, 530 &SyncBackendHostCore::DoFinishConfigureDataTypes,
523 weak_ptr_factory_.GetWeakPtr(), params.to_download, params.ready_task)); 531 weak_ptr_factory_.GetWeakPtr(), params.to_download, params.ready_task));
524 base::Closure chained_retry_task( 532 base::Closure chained_retry_task(
525 base::Bind(&SyncBackendHostCore::DoRetryConfiguration, 533 base::Bind(&SyncBackendHostCore::DoRetryConfiguration,
526 weak_ptr_factory_.GetWeakPtr(), params.retry_callback)); 534 weak_ptr_factory_.GetWeakPtr(), params.retry_callback));
527 535
528 sync_manager_->ConfigureSyncer(params.reason, params.to_download, 536 sync_manager_->ConfigureSyncer(params.reason, params.to_download,
529 routing_info, chained_ready_task, 537 chained_ready_task, chained_retry_task);
530 chained_retry_task);
531 } 538 }
532 539
533 void SyncBackendHostCore::DoFinishConfigureDataTypes( 540 void SyncBackendHostCore::DoFinishConfigureDataTypes(
534 ModelTypeSet types_to_config, 541 ModelTypeSet types_to_config,
535 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { 542 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) {
536 DCHECK(thread_checker_.CalledOnValidThread()); 543 DCHECK(thread_checker_.CalledOnValidThread());
537 544
538 // Update the enabled types for the bridge and sync manager. 545 // Update the enabled types for the bridge and sync manager.
539 ModelSafeRoutingInfo routing_info; 546 ModelSafeRoutingInfo routing_info;
540 registrar_->GetModelSafeRoutingInfo(&routing_info); 547 registrar_->GetModelSafeRoutingInfo(&routing_info);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 643 }
637 644
638 void SyncBackendHostCore::ClearServerDataDone( 645 void SyncBackendHostCore::ClearServerDataDone(
639 const base::Closure& frontend_callback) { 646 const base::Closure& frontend_callback) {
640 DCHECK(thread_checker_.CalledOnValidThread()); 647 DCHECK(thread_checker_.CalledOnValidThread());
641 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 648 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
642 frontend_callback); 649 frontend_callback);
643 } 650 }
644 651
645 } // namespace syncer 652 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698