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

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

Issue 2644373003: Revert of [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 registered in ModelTypeRegistry. Register them here.
147 ModelTypeConnector* model_type_connector =
148 sync_manager_->GetModelTypeConnector();
149 ModelTypeSet control_types = ControlTypes();
150 for (auto it = control_types.First(); it.Good(); it.Inc()) {
151 model_type_connector->RegisterDirectoryType(it.Get(), GROUP_PASSIVE);
152 }
153
154 ModelSafeRoutingInfo routing_info; 144 ModelSafeRoutingInfo routing_info;
155 registrar_->GetModelSafeRoutingInfo(&routing_info); 145 registrar_->GetModelSafeRoutingInfo(&routing_info);
156 SDVLOG(1) << "Control Types " << ModelTypeSetToString(new_control_types) 146 SDVLOG(1) << "Control Types " << ModelTypeSetToString(new_control_types)
157 << " added; calling ConfigureSyncer"; 147 << " added; calling ConfigureSyncer";
158 148
159 ModelTypeSet types_to_purge = 149 ModelTypeSet types_to_purge =
160 Difference(ModelTypeSet::All(), GetRoutingInfoTypes(routing_info)); 150 Difference(ModelTypeSet::All(), GetRoutingInfoTypes(routing_info));
161 151
162 sync_manager_->PurgeDisabledTypes(types_to_purge, ModelTypeSet(), 152 sync_manager_->PurgeDisabledTypes(types_to_purge, ModelTypeSet(),
163 ModelTypeSet()); 153 ModelTypeSet());
164 sync_manager_->ConfigureSyncer( 154 sync_manager_->ConfigureSyncer(
165 reason, new_control_types, 155 reason, new_control_types, routing_info,
166 base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes, 156 base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes,
167 weak_ptr_factory_.GetWeakPtr()), 157 weak_ptr_factory_.GetWeakPtr()),
168 base::Closure()); 158 base::Closure());
169 } 159 }
170 160
171 void SyncBackendHostCore::OnConnectionStatusChange(ConnectionStatus status) { 161 void SyncBackendHostCore::OnConnectionStatusChange(ConnectionStatus status) {
172 DCHECK(thread_checker_.CalledOnValidThread()); 162 DCHECK(thread_checker_.CalledOnValidThread());
173 host_.Call(FROM_HERE, 163 host_.Call(FROM_HERE,
174 &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop, 164 &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop,
175 status); 165 status);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 DCHECK(thread_checker_.CalledOnValidThread()); 382 DCHECK(thread_checker_.CalledOnValidThread());
393 // UpdateCredentials can be called during backend initialization, possibly 383 // UpdateCredentials can be called during backend initialization, possibly
394 // when backend initialization has failed but hasn't notified the UI thread 384 // when backend initialization has failed but hasn't notified the UI thread
395 // yet. In that case, the sync manager may have been destroyed on the sync 385 // yet. In that case, the sync manager may have been destroyed on the sync
396 // thread before this task was executed, so we do nothing. 386 // thread before this task was executed, so we do nothing.
397 if (sync_manager_) { 387 if (sync_manager_) {
398 sync_manager_->UpdateCredentials(credentials); 388 sync_manager_->UpdateCredentials(credentials);
399 } 389 }
400 } 390 }
401 391
402 void SyncBackendHostCore::DoStartConfiguration() { 392 void SyncBackendHostCore::DoStartSyncing(
403 sync_manager_->StartConfiguration(); 393 const ModelSafeRoutingInfo& routing_info,
404 } 394 base::Time last_poll_time) {
405
406 void SyncBackendHostCore::DoStartSyncing(base::Time last_poll_time) {
407 DCHECK(thread_checker_.CalledOnValidThread()); 395 DCHECK(thread_checker_.CalledOnValidThread());
408 sync_manager_->StartSyncingNormally(last_poll_time); 396 sync_manager_->StartSyncingNormally(routing_info, last_poll_time);
409 } 397 }
410 398
411 void SyncBackendHostCore::DoSetEncryptionPassphrase( 399 void SyncBackendHostCore::DoSetEncryptionPassphrase(
412 const std::string& passphrase, 400 const std::string& passphrase,
413 bool is_explicit) { 401 bool is_explicit) {
414 DCHECK(thread_checker_.CalledOnValidThread()); 402 DCHECK(thread_checker_.CalledOnValidThread());
415 sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(passphrase, 403 sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(passphrase,
416 is_explicit); 404 is_explicit);
417 } 405 }
418 406
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 508 }
521 509
522 void SyncBackendHostCore::DoConfigureSyncer( 510 void SyncBackendHostCore::DoConfigureSyncer(
523 ModelTypeConfigurer::ConfigureParams params) { 511 ModelTypeConfigurer::ConfigureParams params) {
524 DCHECK(thread_checker_.CalledOnValidThread()); 512 DCHECK(thread_checker_.CalledOnValidThread());
525 DCHECK(!params.ready_task.is_null()); 513 DCHECK(!params.ready_task.is_null());
526 DCHECK(!params.retry_callback.is_null()); 514 DCHECK(!params.retry_callback.is_null());
527 515
528 registrar_->ConfigureDataTypes(params.enabled_types, params.disabled_types); 516 registrar_->ConfigureDataTypes(params.enabled_types, params.disabled_types);
529 517
518 ModelSafeRoutingInfo routing_info;
519 registrar_->GetModelSafeRoutingInfo(&routing_info);
520
530 base::Closure chained_ready_task(base::Bind( 521 base::Closure chained_ready_task(base::Bind(
531 &SyncBackendHostCore::DoFinishConfigureDataTypes, 522 &SyncBackendHostCore::DoFinishConfigureDataTypes,
532 weak_ptr_factory_.GetWeakPtr(), params.to_download, params.ready_task)); 523 weak_ptr_factory_.GetWeakPtr(), params.to_download, params.ready_task));
533 base::Closure chained_retry_task( 524 base::Closure chained_retry_task(
534 base::Bind(&SyncBackendHostCore::DoRetryConfiguration, 525 base::Bind(&SyncBackendHostCore::DoRetryConfiguration,
535 weak_ptr_factory_.GetWeakPtr(), params.retry_callback)); 526 weak_ptr_factory_.GetWeakPtr(), params.retry_callback));
536 527
537 sync_manager_->ConfigureSyncer(params.reason, params.to_download, 528 sync_manager_->ConfigureSyncer(params.reason, params.to_download,
538 chained_ready_task, chained_retry_task); 529 routing_info, chained_ready_task,
530 chained_retry_task);
539 } 531 }
540 532
541 void SyncBackendHostCore::DoFinishConfigureDataTypes( 533 void SyncBackendHostCore::DoFinishConfigureDataTypes(
542 ModelTypeSet types_to_config, 534 ModelTypeSet types_to_config,
543 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { 535 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) {
544 DCHECK(thread_checker_.CalledOnValidThread()); 536 DCHECK(thread_checker_.CalledOnValidThread());
545 537
546 // Update the enabled types for the bridge and sync manager. 538 // Update the enabled types for the bridge and sync manager.
547 ModelSafeRoutingInfo routing_info; 539 ModelSafeRoutingInfo routing_info;
548 registrar_->GetModelSafeRoutingInfo(&routing_info); 540 registrar_->GetModelSafeRoutingInfo(&routing_info);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } 636 }
645 637
646 void SyncBackendHostCore::ClearServerDataDone( 638 void SyncBackendHostCore::ClearServerDataDone(
647 const base::Closure& frontend_callback) { 639 const base::Closure& frontend_callback) {
648 DCHECK(thread_checker_.CalledOnValidThread()); 640 DCHECK(thread_checker_.CalledOnValidThread());
649 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, 641 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
650 frontend_callback); 642 frontend_callback);
651 } 643 }
652 644
653 } // namespace syncer 645 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_core.h ('k') | components/sync/driver/glue/sync_backend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698