| Index: components/sync/driver/glue/sync_backend_host_core.cc
|
| diff --git a/components/sync_driver/glue/sync_backend_host_core.cc b/components/sync/driver/glue/sync_backend_host_core.cc
|
| similarity index 85%
|
| rename from components/sync_driver/glue/sync_backend_host_core.cc
|
| rename to components/sync/driver/glue/sync_backend_host_core.cc
|
| index 81ee0f761c98345406471d9bee5f88a0e6f73b0b..e0710aa79e61194f740739d733022f9fbe0448e8 100644
|
| --- a/components/sync_driver/glue/sync_backend_host_core.cc
|
| +++ b/components/sync/driver/glue/sync_backend_host_core.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "components/sync_driver/glue/sync_backend_host_core.h"
|
| +#include "components/sync/driver/glue/sync_backend_host_core.h"
|
|
|
| #include <utility>
|
|
|
| @@ -17,14 +17,14 @@
|
| #include "components/sync/core/internal_components_factory.h"
|
| #include "components/sync/core/sync_manager.h"
|
| #include "components/sync/core/sync_manager_factory.h"
|
| +#include "components/sync/driver/glue/sync_backend_registrar.h"
|
| +#include "components/sync/driver/invalidation_adapter.h"
|
| +#include "components/sync/driver/local_device_info_provider_impl.h"
|
| #include "components/sync/engine/events/protocol_event.h"
|
| #include "components/sync/sessions/commit_counters.h"
|
| #include "components/sync/sessions/status_counters.h"
|
| #include "components/sync/sessions/sync_session_snapshot.h"
|
| #include "components/sync/sessions/update_counters.h"
|
| -#include "components/sync_driver/glue/sync_backend_registrar.h"
|
| -#include "components/sync_driver/invalidation_adapter.h"
|
| -#include "components/sync_driver/local_device_info_provider_impl.h"
|
| #include "url/gurl.h"
|
|
|
| // Helper macros to log with the syncer thread name; useful when there
|
| @@ -135,10 +135,9 @@ void SyncBackendHostCore::OnSyncCycleCompleted(
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
|
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop,
|
| - snapshot);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleSyncCycleCompletedOnFrontendLoop,
|
| + snapshot);
|
| }
|
|
|
| void SyncBackendHostCore::DoRefreshTypes(syncer::ModelTypeSet types) {
|
| @@ -187,9 +186,8 @@ void SyncBackendHostCore::OnInitializationComplete(
|
| registrar_->SetInitialTypes(restored_types);
|
|
|
| syncer::ConfigureReason reason =
|
| - restored_types.Empty() ?
|
| - syncer::CONFIGURE_REASON_NEW_CLIENT :
|
| - syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
|
| + restored_types.Empty() ? syncer::CONFIGURE_REASON_NEW_CLIENT
|
| + : syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
|
|
|
| syncer::ModelTypeSet new_control_types = registrar_->ConfigureDataTypes(
|
| syncer::ControlTypes(), syncer::ModelTypeSet());
|
| @@ -199,17 +197,12 @@ void SyncBackendHostCore::OnInitializationComplete(
|
| << syncer::ModelTypeSetToString(new_control_types)
|
| << " added; calling ConfigureSyncer";
|
|
|
| - syncer::ModelTypeSet types_to_purge =
|
| - syncer::Difference(syncer::ModelTypeSet::All(),
|
| - GetRoutingInfoTypes(routing_info));
|
| + syncer::ModelTypeSet types_to_purge = syncer::Difference(
|
| + syncer::ModelTypeSet::All(), GetRoutingInfoTypes(routing_info));
|
|
|
| sync_manager_->ConfigureSyncer(
|
| - reason,
|
| - new_control_types,
|
| - types_to_purge,
|
| - syncer::ModelTypeSet(),
|
| - syncer::ModelTypeSet(),
|
| - routing_info,
|
| + reason, new_control_types, types_to_purge, syncer::ModelTypeSet(),
|
| + syncer::ModelTypeSet(), routing_info,
|
| base::Bind(&SyncBackendHostCore::DoInitialProcessControlTypes,
|
| weak_ptr_factory_.GetWeakPtr()),
|
| base::Closure());
|
| @@ -220,9 +213,9 @@ void SyncBackendHostCore::OnConnectionStatusChange(
|
| if (!sync_loop_)
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop, status);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop,
|
| + status);
|
| }
|
|
|
| void SyncBackendHostCore::OnPassphraseRequired(
|
| @@ -231,18 +224,15 @@ void SyncBackendHostCore::OnPassphraseRequired(
|
| if (!sync_loop_)
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::NotifyPassphraseRequired, reason, pending_keys);
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::NotifyPassphraseRequired, reason,
|
| + pending_keys);
|
| }
|
|
|
| void SyncBackendHostCore::OnPassphraseAccepted() {
|
| if (!sync_loop_)
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::NotifyPassphraseAccepted);
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::NotifyPassphraseAccepted);
|
| }
|
|
|
| void SyncBackendHostCore::OnBootstrapTokenUpdated(
|
| @@ -251,10 +241,8 @@ void SyncBackendHostCore::OnBootstrapTokenUpdated(
|
| if (!sync_loop_)
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(FROM_HERE,
|
| - &SyncBackendHostImpl::PersistEncryptionBootstrapToken,
|
| - bootstrap_token,
|
| - type);
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::PersistEncryptionBootstrapToken,
|
| + bootstrap_token, type);
|
| }
|
|
|
| void SyncBackendHostCore::OnEncryptedTypesChanged(
|
| @@ -264,10 +252,8 @@ void SyncBackendHostCore::OnEncryptedTypesChanged(
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| // NOTE: We're in a transaction.
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::NotifyEncryptedTypesChanged,
|
| - encrypted_types, encrypt_everything);
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::NotifyEncryptedTypesChanged,
|
| + encrypted_types, encrypt_everything);
|
| }
|
|
|
| void SyncBackendHostCore::OnEncryptionComplete() {
|
| @@ -275,9 +261,7 @@ void SyncBackendHostCore::OnEncryptionComplete() {
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| // NOTE: We're in a transaction.
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::NotifyEncryptionComplete);
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::NotifyEncryptionComplete);
|
| }
|
|
|
| void SyncBackendHostCore::OnCryptographerStateChanged(
|
| @@ -285,12 +269,11 @@ void SyncBackendHostCore::OnCryptographerStateChanged(
|
| // Do nothing.
|
| }
|
|
|
| -void SyncBackendHostCore::OnPassphraseTypeChanged(
|
| - syncer::PassphraseType type, base::Time passphrase_time) {
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop,
|
| - type, passphrase_time);
|
| +void SyncBackendHostCore::OnPassphraseTypeChanged(syncer::PassphraseType type,
|
| + base::Time passphrase_time) {
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandlePassphraseTypeChangedOnFrontendLoop,
|
| + type, passphrase_time);
|
| }
|
|
|
| void SyncBackendHostCore::OnLocalSetPassphraseEncryption(
|
| @@ -333,29 +316,25 @@ void SyncBackendHostCore::OnActionableError(
|
| if (!sync_loop_)
|
| return;
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop,
|
| - sync_error);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop,
|
| + sync_error);
|
| }
|
|
|
| void SyncBackendHostCore::OnMigrationRequested(syncer::ModelTypeSet types) {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop,
|
| - types);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop,
|
| + types);
|
| }
|
|
|
| -void SyncBackendHostCore::OnProtocolEvent(
|
| - const syncer::ProtocolEvent& event) {
|
| +void SyncBackendHostCore::OnProtocolEvent(const syncer::ProtocolEvent& event) {
|
| // TODO(rlarocque): Find a way to pass event_clone as a scoped_ptr.
|
| if (forward_protocol_events_) {
|
| std::unique_ptr<syncer::ProtocolEvent> event_clone(event.Clone());
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop,
|
| - event_clone.release());
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop,
|
| + event_clone.release());
|
| }
|
| }
|
|
|
| @@ -398,10 +377,8 @@ void SyncBackendHostCore::DoOnIncomingInvalidation(
|
| }
|
| }
|
|
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::UpdateInvalidationVersions,
|
| - last_invalidation_versions_);
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::UpdateInvalidationVersions,
|
| + last_invalidation_versions_);
|
| }
|
|
|
| void SyncBackendHostCore::DoInitialize(
|
| @@ -484,8 +461,8 @@ void SyncBackendHostCore::DoSetEncryptionPassphrase(
|
| const std::string& passphrase,
|
| bool is_explicit) {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(
|
| - passphrase, is_explicit);
|
| + sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(passphrase,
|
| + is_explicit);
|
| }
|
|
|
| void SyncBackendHostCore::DoInitialProcessControlTypes() {
|
| @@ -502,17 +479,15 @@ void SyncBackendHostCore::DoInitialProcessControlTypes() {
|
|
|
| if (!sync_manager_->GetUserShare()) { // NULL in some tests.
|
| DVLOG(1) << "Skipping initialization of DeviceInfo";
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop);
|
| return;
|
| }
|
|
|
| if (!sync_manager_->InitialSyncEndedTypes().HasAll(syncer::ControlTypes())) {
|
| LOG(ERROR) << "Failed to download control types";
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleInitializationFailureOnFrontendLoop);
|
| return;
|
| }
|
|
|
| @@ -529,8 +504,7 @@ void SyncBackendHostCore::DoInitialProcessControlTypes() {
|
| void SyncBackendHostCore::DoSetDecryptionPassphrase(
|
| const std::string& passphrase) {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - sync_manager_->GetEncryptionHandler()->SetDecryptionPassphrase(
|
| - passphrase);
|
| + sync_manager_->GetEncryptionHandler()->SetDecryptionPassphrase(passphrase);
|
| }
|
|
|
| void SyncBackendHostCore::DoEnableEncryptEverything() {
|
| @@ -588,35 +562,28 @@ void SyncBackendHostCore::DoConfigureSyncer(
|
| syncer::ConfigureReason reason,
|
| const DoConfigureSyncerTypes& config_types,
|
| const syncer::ModelSafeRoutingInfo routing_info,
|
| - const base::Callback<void(syncer::ModelTypeSet,
|
| - syncer::ModelTypeSet)>& ready_task,
|
| + const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
|
| + ready_task,
|
| const base::Closure& retry_callback) {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| DCHECK(!ready_task.is_null());
|
| DCHECK(!retry_callback.is_null());
|
| - base::Closure chained_ready_task(
|
| - base::Bind(&SyncBackendHostCore::DoFinishConfigureDataTypes,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - config_types.to_download,
|
| - ready_task));
|
| + base::Closure chained_ready_task(base::Bind(
|
| + &SyncBackendHostCore::DoFinishConfigureDataTypes,
|
| + weak_ptr_factory_.GetWeakPtr(), config_types.to_download, ready_task));
|
| base::Closure chained_retry_task(
|
| base::Bind(&SyncBackendHostCore::DoRetryConfiguration,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - retry_callback));
|
| - sync_manager_->ConfigureSyncer(reason,
|
| - config_types.to_download,
|
| - config_types.to_purge,
|
| - config_types.to_journal,
|
| - config_types.to_unapply,
|
| - routing_info,
|
| - chained_ready_task,
|
| - chained_retry_task);
|
| + weak_ptr_factory_.GetWeakPtr(), retry_callback));
|
| + sync_manager_->ConfigureSyncer(reason, config_types.to_download,
|
| + config_types.to_purge, config_types.to_journal,
|
| + config_types.to_unapply, routing_info,
|
| + chained_ready_task, chained_retry_task);
|
| }
|
|
|
| void SyncBackendHostCore::DoFinishConfigureDataTypes(
|
| syncer::ModelTypeSet types_to_config,
|
| - const base::Callback<void(syncer::ModelTypeSet,
|
| - syncer::ModelTypeSet)>& ready_task) {
|
| + const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
|
| + ready_task) {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
|
|
| // Update the enabled types for the bridge and sync manager.
|
| @@ -631,17 +598,14 @@ void SyncBackendHostCore::DoFinishConfigureDataTypes(
|
| Difference(types_to_config, failed_configuration_types);
|
| host_.Call(FROM_HERE,
|
| &SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop,
|
| - enabled_types,
|
| - succeeded_configuration_types,
|
| - failed_configuration_types,
|
| - ready_task);
|
| + enabled_types, succeeded_configuration_types,
|
| + failed_configuration_types, ready_task);
|
| }
|
|
|
| void SyncBackendHostCore::DoRetryConfiguration(
|
| const base::Closure& retry_callback) {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| - host_.Call(FROM_HERE,
|
| - &SyncBackendHostImpl::RetryConfigurationOnFrontendLoop,
|
| + host_.Call(FROM_HERE, &SyncBackendHostImpl::RetryConfigurationOnFrontendLoop,
|
| retry_callback);
|
| }
|
|
|
| @@ -657,12 +621,11 @@ void SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding() {
|
|
|
| // Send them all over the fence to the host.
|
| for (std::vector<syncer::ProtocolEvent*>::iterator it =
|
| - buffered_events.begin(); it != buffered_events.end(); ++it) {
|
| + buffered_events.begin();
|
| + it != buffered_events.end(); ++it) {
|
| // TODO(rlarocque): Make it explicit that host_ takes ownership.
|
| - host_.Call(
|
| - FROM_HERE,
|
| - &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop,
|
| - *it);
|
| + host_.Call(FROM_HERE,
|
| + &SyncBackendHostImpl::HandleProtocolEventOnFrontendLoop, *it);
|
| }
|
| }
|
| }
|
| @@ -724,8 +687,7 @@ void SyncBackendHostCore::GetAllNodesForTypes(
|
| }
|
|
|
| task_runner->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(callback, types_vector, base::Passed(&node_lists)));
|
| + FROM_HERE, base::Bind(callback, types_vector, base::Passed(&node_lists)));
|
| }
|
|
|
| void SyncBackendHostCore::StartSavingChanges() {
|
| @@ -735,8 +697,8 @@ void SyncBackendHostCore::StartSavingChanges() {
|
| DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
|
| DCHECK(!save_changes_timer_.get());
|
| save_changes_timer_.reset(new base::RepeatingTimer());
|
| - save_changes_timer_->Start(FROM_HERE,
|
| - base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
|
| + save_changes_timer_->Start(
|
| + FROM_HERE, base::TimeDelta::FromSeconds(kSaveChangesIntervalSeconds),
|
| this, &SyncBackendHostCore::SaveChanges);
|
| }
|
|
|
| @@ -767,5 +729,4 @@ void SyncBackendHostCore::ClearServerDataDone(
|
| frontend_callback);
|
| }
|
|
|
| -
|
| } // namespace browser_sync
|
|
|