| Index: components/sync/driver/model_association_manager.cc
|
| diff --git a/components/sync_driver/model_association_manager.cc b/components/sync/driver/model_association_manager.cc
|
| similarity index 76%
|
| rename from components/sync_driver/model_association_manager.cc
|
| rename to components/sync/driver/model_association_manager.cc
|
| index 0c69b7bb180f77ff8f1547ecd0d02954fe845e4c..55d59286000fdff6525982f488b576fe276d8d79 100644
|
| --- a/components/sync_driver/model_association_manager.cc
|
| +++ b/components/sync/driver/model_association_manager.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/model_association_manager.h"
|
| +#include "components/sync/driver/model_association_manager.h"
|
|
|
| #include <stddef.h>
|
| #include <stdint.h>
|
| @@ -25,52 +25,35 @@ namespace sync_driver {
|
| namespace {
|
|
|
| static const syncer::ModelType kStartOrder[] = {
|
| - syncer::NIGORI, // Listed for completeness.
|
| - syncer::DEVICE_INFO, // Listed for completeness.
|
| - syncer::EXPERIMENTS, // Listed for completeness.
|
| - syncer::PROXY_TABS, // Listed for completeness.
|
| -
|
| - // Kick off the association of the non-UI types first so they can associate
|
| - // in parallel with the UI types.
|
| - syncer::PASSWORDS,
|
| - syncer::AUTOFILL,
|
| - syncer::AUTOFILL_PROFILE,
|
| - syncer::AUTOFILL_WALLET_DATA,
|
| - syncer::AUTOFILL_WALLET_METADATA,
|
| - syncer::EXTENSION_SETTINGS,
|
| - syncer::APP_SETTINGS,
|
| - syncer::TYPED_URLS,
|
| - syncer::HISTORY_DELETE_DIRECTIVES,
|
| - syncer::SYNCED_NOTIFICATIONS,
|
| - syncer::SYNCED_NOTIFICATION_APP_INFO,
|
| -
|
| - // UI thread data types.
|
| - syncer::BOOKMARKS,
|
| - syncer::SUPERVISED_USERS, // Syncing supervised users on initial login
|
| - // might block creating a new supervised user,
|
| - // so we want to do it early.
|
| - syncer::PREFERENCES,
|
| - syncer::PRIORITY_PREFERENCES,
|
| - syncer::EXTENSIONS,
|
| - syncer::APPS,
|
| - syncer::APP_LIST,
|
| - syncer::ARC_PACKAGE,
|
| - syncer::THEMES,
|
| - syncer::SEARCH_ENGINES,
|
| - syncer::SESSIONS,
|
| - syncer::APP_NOTIFICATIONS,
|
| - syncer::DICTIONARY,
|
| - syncer::FAVICON_IMAGES,
|
| - syncer::FAVICON_TRACKING,
|
| - syncer::SUPERVISED_USER_SETTINGS,
|
| - syncer::SUPERVISED_USER_SHARED_SETTINGS,
|
| - syncer::SUPERVISED_USER_WHITELISTS,
|
| - syncer::ARTICLES,
|
| - syncer::WIFI_CREDENTIALS,
|
| + syncer::NIGORI, // Listed for completeness.
|
| + syncer::DEVICE_INFO, // Listed for completeness.
|
| + syncer::EXPERIMENTS, // Listed for completeness.
|
| + syncer::PROXY_TABS, // Listed for completeness.
|
| +
|
| + // Kick off the association of the non-UI types first so they can associate
|
| + // in parallel with the UI types.
|
| + syncer::PASSWORDS, syncer::AUTOFILL, syncer::AUTOFILL_PROFILE,
|
| + syncer::AUTOFILL_WALLET_DATA, syncer::AUTOFILL_WALLET_METADATA,
|
| + syncer::EXTENSION_SETTINGS, syncer::APP_SETTINGS, syncer::TYPED_URLS,
|
| + syncer::HISTORY_DELETE_DIRECTIVES, syncer::SYNCED_NOTIFICATIONS,
|
| + syncer::SYNCED_NOTIFICATION_APP_INFO,
|
| +
|
| + // UI thread data types.
|
| + syncer::BOOKMARKS,
|
| + syncer::SUPERVISED_USERS, // Syncing supervised users on initial login
|
| + // might block creating a new supervised user,
|
| + // so we want to do it early.
|
| + syncer::PREFERENCES, syncer::PRIORITY_PREFERENCES, syncer::EXTENSIONS,
|
| + syncer::APPS, syncer::APP_LIST, syncer::ARC_PACKAGE, syncer::THEMES,
|
| + syncer::SEARCH_ENGINES, syncer::SESSIONS, syncer::APP_NOTIFICATIONS,
|
| + syncer::DICTIONARY, syncer::FAVICON_IMAGES, syncer::FAVICON_TRACKING,
|
| + syncer::SUPERVISED_USER_SETTINGS, syncer::SUPERVISED_USER_SHARED_SETTINGS,
|
| + syncer::SUPERVISED_USER_WHITELISTS, syncer::ARTICLES,
|
| + syncer::WIFI_CREDENTIALS,
|
| };
|
|
|
| static_assert(arraysize(kStartOrder) ==
|
| - syncer::MODEL_TYPE_COUNT - syncer::FIRST_REAL_MODEL_TYPE,
|
| + syncer::MODEL_TYPE_COUNT - syncer::FIRST_REAL_MODEL_TYPE,
|
| "kStartOrder must have MODEL_TYPE_COUNT - "
|
| "FIRST_REAL_MODEL_TYPE elements");
|
|
|
| @@ -86,8 +69,8 @@ syncer::DataTypeAssociationStats BuildAssociationStatsFromMergeResults(
|
| const base::TimeDelta& association_time) {
|
| DCHECK_EQ(local_merge_result.model_type(), syncer_merge_result.model_type());
|
| syncer::DataTypeAssociationStats stats;
|
| - stats.had_error = local_merge_result.error().IsSet() ||
|
| - syncer_merge_result.error().IsSet();
|
| + stats.had_error =
|
| + local_merge_result.error().IsSet() || syncer_merge_result.error().IsSet();
|
| stats.num_local_items_before_association =
|
| local_merge_result.num_items_before_association();
|
| stats.num_sync_items_before_association =
|
| @@ -96,20 +79,14 @@ syncer::DataTypeAssociationStats BuildAssociationStatsFromMergeResults(
|
| local_merge_result.num_items_after_association();
|
| stats.num_sync_items_after_association =
|
| syncer_merge_result.num_items_after_association();
|
| - stats.num_local_items_added =
|
| - local_merge_result.num_items_added();
|
| - stats.num_local_items_deleted =
|
| - local_merge_result.num_items_deleted();
|
| - stats.num_local_items_modified =
|
| - local_merge_result.num_items_modified();
|
| + stats.num_local_items_added = local_merge_result.num_items_added();
|
| + stats.num_local_items_deleted = local_merge_result.num_items_deleted();
|
| + stats.num_local_items_modified = local_merge_result.num_items_modified();
|
| stats.local_version_pre_association =
|
| local_merge_result.pre_association_version();
|
| - stats.num_sync_items_added =
|
| - syncer_merge_result.num_items_added();
|
| - stats.num_sync_items_deleted =
|
| - syncer_merge_result.num_items_deleted();
|
| - stats.num_sync_items_modified =
|
| - syncer_merge_result.num_items_modified();
|
| + stats.num_sync_items_added = syncer_merge_result.num_items_added();
|
| + stats.num_sync_items_deleted = syncer_merge_result.num_items_deleted();
|
| + stats.num_sync_items_modified = syncer_merge_result.num_items_modified();
|
| stats.sync_version_pre_association =
|
| syncer_merge_result.pre_association_version();
|
| stats.association_wait_time = association_wait_time;
|
| @@ -135,8 +112,7 @@ ModelAssociationManager::ModelAssociationManager(
|
| }
|
| }
|
|
|
| -ModelAssociationManager::~ModelAssociationManager() {
|
| -}
|
| +ModelAssociationManager::~ModelAssociationManager() {}
|
|
|
| void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
|
| // state_ can be INITIALIZED if types are reconfigured when
|
| @@ -146,8 +122,8 @@ void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
|
|
|
| // Only keep types that have controllers.
|
| desired_types_.Clear();
|
| - for (syncer::ModelTypeSet::Iterator it = desired_types.First();
|
| - it.Good(); it.Inc()) {
|
| + for (syncer::ModelTypeSet::Iterator it = desired_types.First(); it.Good();
|
| + it.Inc()) {
|
| if (controllers_->find(it.Get()) != controllers_->end())
|
| desired_types_.Put(it.Get());
|
| }
|
| @@ -162,9 +138,8 @@ void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
|
| LoadEnabledTypes();
|
| }
|
|
|
| -void ModelAssociationManager::StopDatatype(
|
| - const syncer::SyncError& error,
|
| - DataTypeController* dtc) {
|
| +void ModelAssociationManager::StopDatatype(const syncer::SyncError& error,
|
| + DataTypeController* dtc) {
|
| loaded_types_.Remove(dtc->type());
|
| associated_types_.Remove(dtc->type());
|
| associating_types_.Remove(dtc->type());
|
| @@ -235,8 +210,7 @@ void ModelAssociationManager::StartAssociationAsync(
|
| timer_.Start(FROM_HERE,
|
| base::TimeDelta::FromSeconds(kAssociationTimeOutInSeconds),
|
| base::Bind(&ModelAssociationManager::ModelAssociationDone,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - INITIALIZED));
|
| + weak_ptr_factory_.GetWeakPtr(), INITIALIZED));
|
|
|
| // Start association of types that are loaded in specified order.
|
| for (size_t i = 0; i < arraysize(kStartOrder); i++) {
|
| @@ -248,15 +222,12 @@ void ModelAssociationManager::StartAssociationAsync(
|
| DCHECK(DataTypeController::MODEL_LOADED == dtc->state() ||
|
| DataTypeController::ASSOCIATING == dtc->state());
|
| if (dtc->state() == DataTypeController::MODEL_LOADED) {
|
| - TRACE_EVENT_ASYNC_BEGIN1("sync", "ModelAssociation",
|
| - dtc,
|
| - "DataType",
|
| + TRACE_EVENT_ASYNC_BEGIN1("sync", "ModelAssociation", dtc, "DataType",
|
| ModelTypeToString(type));
|
|
|
| - dtc->StartAssociating(
|
| - base::Bind(&ModelAssociationManager::TypeStartCallback,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - type, base::TimeTicks::Now()));
|
| + dtc->StartAssociating(base::Bind(
|
| + &ModelAssociationManager::TypeStartCallback,
|
| + weak_ptr_factory_.GetWeakPtr(), type, base::TimeTicks::Now()));
|
| }
|
| }
|
| }
|
| @@ -294,16 +265,14 @@ void ModelAssociationManager::Stop() {
|
| void ModelAssociationManager::ModelLoadCallback(syncer::ModelType type,
|
| syncer::SyncError error) {
|
| DVLOG(1) << "ModelAssociationManager: ModelLoadCallback for "
|
| - << syncer::ModelTypeToString(type);
|
| + << syncer::ModelTypeToString(type);
|
|
|
| if (error.IsSet()) {
|
| syncer::SyncMergeResult local_merge_result(type);
|
| local_merge_result.set_error(error);
|
| - TypeStartCallback(type,
|
| - base::TimeTicks::Now(),
|
| + TypeStartCallback(type, base::TimeTicks::Now(),
|
| DataTypeController::ASSOCIATION_FAILED,
|
| - local_merge_result,
|
| - syncer::SyncMergeResult(type));
|
| + local_merge_result, syncer::SyncMergeResult(type));
|
| return;
|
| }
|
|
|
| @@ -353,11 +322,11 @@ void ModelAssociationManager::TypeStartCallback(
|
| // This happens when a slow associating type is disabled or if a type
|
| // disables itself after initial configuration.
|
| if (!desired_types_.Has(type)) {
|
| - // It's possible all types failed to associate, in which case association
|
| - // is complete.
|
| - if (state_ == ASSOCIATING && associating_types_.Empty())
|
| - ModelAssociationDone(INITIALIZED);
|
| - return;
|
| + // It's possible all types failed to associate, in which case association
|
| + // is complete.
|
| + if (state_ == ASSOCIATING && associating_types_.Empty())
|
| + ModelAssociationDone(INITIALIZED);
|
| + return;
|
| }
|
|
|
| DCHECK(!associated_types_.Has(type));
|
| @@ -368,8 +337,7 @@ void ModelAssociationManager::TypeStartCallback(
|
| return;
|
|
|
| TRACE_EVENT_ASYNC_END1("sync", "ModelAssociation",
|
| - controllers_->find(type)->second.get(),
|
| - "DataType",
|
| + controllers_->find(type)->second.get(), "DataType",
|
| ModelTypeToString(type));
|
|
|
| // Track the merge results if we succeeded or an association failure
|
| @@ -377,13 +345,11 @@ void ModelAssociationManager::TypeStartCallback(
|
| if (syncer::ProtocolTypes().Has(type)) {
|
| base::TimeDelta association_wait_time =
|
| std::max(base::TimeDelta(), type_start_time - association_start_time_);
|
| - base::TimeDelta association_time =
|
| - base::TimeTicks::Now() - type_start_time;
|
| + base::TimeDelta association_time = base::TimeTicks::Now() - type_start_time;
|
| syncer::DataTypeAssociationStats stats =
|
| - BuildAssociationStatsFromMergeResults(local_merge_result,
|
| - syncer_merge_result,
|
| - association_wait_time,
|
| - association_time);
|
| + BuildAssociationStatsFromMergeResults(
|
| + local_merge_result, syncer_merge_result, association_wait_time,
|
| + association_time);
|
| delegate_->OnSingleDataTypeAssociationDone(type, stats);
|
| }
|
|
|
| @@ -417,16 +383,14 @@ void ModelAssociationManager::ModelAssociationDone(State new_state) {
|
| UMA_HISTOGRAM_ENUMERATION("Sync.ConfigureFailed",
|
| ModelTypeToHistogramInt(dtc->type()),
|
| syncer::MODEL_TYPE_COUNT);
|
| - StopDatatype(syncer::SyncError(FROM_HERE,
|
| - syncer::SyncError::DATATYPE_ERROR,
|
| - "Association timed out.",
|
| - dtc->type()),
|
| - dtc);
|
| + StopDatatype(
|
| + syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
|
| + "Association timed out.", dtc->type()),
|
| + dtc);
|
| }
|
| }
|
|
|
| - DataTypeManager::ConfigureResult result(configure_status_,
|
| - requested_types_);
|
| + DataTypeManager::ConfigureResult result(configure_status_, requested_types_);
|
|
|
| // Need to reset state before invoking delegate in order to avoid re-entrancy
|
| // issues (delegate may trigger a reconfiguration).
|
|
|