Commit 924cf20a authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Clean up comments in DataTypeManagerImpl/ModelLoadManager

This removes some usage of "association" terminology, which is a concept
that doesn't exist anymore. It also adds a few TODOs for further
"proper" cleanups.

Bug: 1102837
Change-Id: Ib628ff6c065ec532065d3c053d0cc7594e7bbd4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2539912Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827755}
parent 62972354
...@@ -476,6 +476,8 @@ void DataTypeManagerImpl::DownloadCompleted( ...@@ -476,6 +476,8 @@ void DataTypeManagerImpl::DownloadCompleted(
needs_reconfigure_ = true; needs_reconfigure_ = true;
} }
// If a reconfigure was requested while this download was ongoing, process it
// now.
if (needs_reconfigure_) { if (needs_reconfigure_) {
download_types_queue_ = base::queue<ModelTypeSet>(); download_types_queue_ = base::queue<ModelTypeSet>();
ProcessReconfigure(); ProcessReconfigure();
...@@ -486,8 +488,7 @@ void DataTypeManagerImpl::DownloadCompleted( ...@@ -486,8 +488,7 @@ void DataTypeManagerImpl::DownloadCompleted(
download_types_queue_.pop(); download_types_queue_.pop();
// Those types that were already downloaded (non first sync/error types) // Those types that were already downloaded (non first sync/error types)
// should already be associating. Just kick off association of the newly // are already done. Just finalize the newly downloaded types if necessary.
// downloaded types if necessary.
if (!association_types_queue_.empty()) { if (!association_types_queue_.empty()) {
association_types_queue_.back().first_sync_types = first_sync_types; association_types_queue_.back().first_sync_types = first_sync_types;
association_types_queue_.back().download_ready_time = base::Time::Now(); association_types_queue_.back().download_ready_time = base::Time::Now();
...@@ -780,8 +781,7 @@ void DataTypeManagerImpl::StopImpl(ShutdownReason reason) { ...@@ -780,8 +781,7 @@ void DataTypeManagerImpl::StopImpl(ShutdownReason reason) {
// Invalidate weak pointer to drop download callbacks. // Invalidate weak pointer to drop download callbacks.
weak_ptr_factory_.InvalidateWeakPtrs(); weak_ptr_factory_.InvalidateWeakPtrs();
// Stop all data types. This may trigger association callback but the // Stop all data types.
// callback will do nothing because state is set to STOPPING above.
model_load_manager_.Stop(reason); model_load_manager_.Stop(reason);
// Individual data type controllers might still be STOPPING, but we don't // Individual data type controllers might still be STOPPING, but we don't
......
...@@ -109,7 +109,7 @@ class DataTypeManagerImpl : public DataTypeManager, ...@@ -109,7 +109,7 @@ class DataTypeManagerImpl : public DataTypeManager,
DataTypeConfigStateMap* state_map); DataTypeConfigStateMap* state_map);
// Prepare the parameters for the configurer's configuration. Returns the set // Prepare the parameters for the configurer's configuration. Returns the set
// of types that are already ready for association. // of types that are already ready for configuration.
ModelTypeSet PrepareConfigureParams( ModelTypeSet PrepareConfigureParams(
ModelTypeConfigurer::ConfigureParams* params); ModelTypeConfigurer::ConfigureParams* params);
...@@ -129,10 +129,10 @@ class DataTypeManagerImpl : public DataTypeManager, ...@@ -129,10 +129,10 @@ class DataTypeManagerImpl : public DataTypeManager,
// was an actual change. // was an actual change.
bool UpdatePreconditionError(ModelType type); bool UpdatePreconditionError(ModelType type);
// Post a task to reconfigure when no downloading or association are running. // Starts a reconfiguration if it's required and no downloads are running.
void ProcessReconfigure(); void ProcessReconfigure();
// Programmatically force reconfiguration of data type (if needed). // Programmatically force reconfiguration of all data types (if needed).
void ForceReconfiguration(); void ForceReconfiguration();
void Restart(); void Restart();
...@@ -155,13 +155,15 @@ class DataTypeManagerImpl : public DataTypeManager, ...@@ -155,13 +155,15 @@ class DataTypeManagerImpl : public DataTypeManager,
// Start download of next set of types in |download_types_queue_| (if // Start download of next set of types in |download_types_queue_| (if
// any exist, does nothing otherwise). // any exist, does nothing otherwise).
// Will kick off association of any new ready types. // Will kick off configuration of any new ready types.
void StartNextDownload(ModelTypeSet high_priority_types_before); void StartNextDownload(ModelTypeSet high_priority_types_before);
// Start association of next batch of data types after association of // Start association of next batch of data types after association of
// previous batch finishes. |group| controls which set of types within // previous batch finishes. |group| controls which set of types within
// an AssociationTypesInfo to associate. Does nothing if model associator // an AssociationTypesInfo to associate.
// is busy performing association. // TODO(crbug.com/1102837): Simplify and rename this. "Association" doesn't
// exist anymore; all this does is record configuration stats and eventually
// update |state_|.
void StartNextAssociation(AssociationGroup group); void StartNextAssociation(AssociationGroup group);
void StopImpl(ShutdownReason reason); void StopImpl(ShutdownReason reason);
...@@ -202,11 +204,11 @@ class DataTypeManagerImpl : public DataTypeManager, ...@@ -202,11 +204,11 @@ class DataTypeManagerImpl : public DataTypeManager,
// The last time Restart() was called. // The last time Restart() was called.
base::Time last_restart_time_; base::Time last_restart_time_;
// Sync's datatype debug info listener, which we pass model association // Sync's datatype debug info listener, which we pass model configuration
// statistics to. // statistics to.
const WeakHandle<DataTypeDebugInfoListener> debug_info_listener_; const WeakHandle<DataTypeDebugInfoListener> debug_info_listener_;
// The manager that handles the model association of the individual types. // The manager that loads the local models of the data types.
ModelLoadManager model_load_manager_; ModelLoadManager model_load_manager_;
// DataTypeManager must have only one observer -- the ProfileSyncService that // DataTypeManager must have only one observer -- the ProfileSyncService that
...@@ -256,7 +258,7 @@ class DataTypeManagerImpl : public DataTypeManager, ...@@ -256,7 +258,7 @@ class DataTypeManagerImpl : public DataTypeManager,
// datatype encryption. // datatype encryption.
const DataTypeEncryptionHandler* encryption_handler_; const DataTypeEncryptionHandler* encryption_handler_;
// Association and time stats of data type configuration. // Timing stats of data type configuration.
std::map<ModelType, DataTypeConfigurationStats> configuration_stats_; std::map<ModelType, DataTypeConfigurationStats> configuration_stats_;
// Configuration process is started when ModelLoadManager notifies // Configuration process is started when ModelLoadManager notifies
......
...@@ -414,6 +414,9 @@ void SyncEngineBackend::DoPurgeDisabledTypes(const ModelTypeSet& to_purge) { ...@@ -414,6 +414,9 @@ void SyncEngineBackend::DoPurgeDisabledTypes(const ModelTypeSet& to_purge) {
// for Nigori we need to do it here. // for Nigori we need to do it here.
// TODO(crbug.com/922900): try to find better way to implement this logic, // TODO(crbug.com/922900): try to find better way to implement this logic,
// it's likely happen only due to BackendMigrator. // it's likely happen only due to BackendMigrator.
// TODO(crbug.com/1142771): Evaluate whether this logic is necessary at all.
// There's no "purging" logic for any other data type, so likely it's not
// necessary for NIGORI either.
sync_manager_->GetModelTypeConnector()->DisconnectDataType(NIGORI); sync_manager_->GetModelTypeConnector()->DisconnectDataType(NIGORI);
nigori_controller_->Stop(ShutdownReason::DISABLE_SYNC, base::DoNothing()); nigori_controller_->Stop(ShutdownReason::DISABLE_SYNC, base::DoNothing());
LoadAndConnectNigoriController(); LoadAndConnectNigoriController();
......
...@@ -101,9 +101,8 @@ TEST_F(SyncModelLoadManagerTest, StopAfterFinish) { ...@@ -101,9 +101,8 @@ TEST_F(SyncModelLoadManagerTest, StopAfterFinish) {
EXPECT_EQ(0, GetController(BOOKMARKS)->model()->clear_metadata_call_count()); EXPECT_EQ(0, GetController(BOOKMARKS)->model()->clear_metadata_call_count());
} }
// Test that model that failed to load between initialization and association // Test that a model that failed to load is reported and stopped properly.
// is reported and stopped properly. TEST_F(SyncModelLoadManagerTest, ModelLoadFail) {
TEST_F(SyncModelLoadManagerTest, ModelLoadFailBeforeAssociationStart) {
controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(BOOKMARKS); controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(BOOKMARKS);
GetController(BOOKMARKS)->model()->SimulateModelError( GetController(BOOKMARKS)->model()->SimulateModelError(
ModelError(FROM_HERE, "Test error")); ModelError(FROM_HERE, "Test error"));
...@@ -335,7 +334,7 @@ TEST_F(SyncModelLoadManagerTest, StopDataType_NotRunning) { ...@@ -335,7 +334,7 @@ TEST_F(SyncModelLoadManagerTest, StopDataType_NotRunning) {
// Test that Initialize stops controllers with KEEP_METADATA for preferred // Test that Initialize stops controllers with KEEP_METADATA for preferred
// types. // types.
TEST_F(SyncModelLoadManagerTest, KeepsMetadataForPreferredDataType) { TEST_F(SyncModelLoadManagerTest, KeepsMetadataForPreferredDataType) {
// Associate model with two data types. // Initialize the manager with two data types.
controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(BOOKMARKS); controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(BOOKMARKS);
controllers_[APPS] = std::make_unique<FakeDataTypeController>(APPS); controllers_[APPS] = std::make_unique<FakeDataTypeController>(APPS);
ModelLoadManager model_load_manager(&controllers_, &delegate_); ModelLoadManager model_load_manager(&controllers_, &delegate_);
...@@ -370,7 +369,7 @@ TEST_F(SyncModelLoadManagerTest, KeepsMetadataForPreferredDataType) { ...@@ -370,7 +369,7 @@ TEST_F(SyncModelLoadManagerTest, KeepsMetadataForPreferredDataType) {
// Test that Initialize stops controllers with CLEAR_METADATA for // Test that Initialize stops controllers with CLEAR_METADATA for
// no-longer-preferred types. // no-longer-preferred types.
TEST_F(SyncModelLoadManagerTest, ClearsMetadataForNotPreferredDataType) { TEST_F(SyncModelLoadManagerTest, ClearsMetadataForNotPreferredDataType) {
// Associate model with two data types. // Initialize the manager with two data types.
controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(BOOKMARKS); controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(BOOKMARKS);
controllers_[APPS] = std::make_unique<FakeDataTypeController>(APPS); controllers_[APPS] = std::make_unique<FakeDataTypeController>(APPS);
ModelLoadManager model_load_manager(&controllers_, &delegate_); ModelLoadManager model_load_manager(&controllers_, &delegate_);
...@@ -404,7 +403,7 @@ TEST_F(SyncModelLoadManagerTest, ClearsMetadataForNotPreferredDataType) { ...@@ -404,7 +403,7 @@ TEST_F(SyncModelLoadManagerTest, ClearsMetadataForNotPreferredDataType) {
} }
TEST_F(SyncModelLoadManagerTest, SwitchFromOnDiskToInMemoryRestartsTypes) { TEST_F(SyncModelLoadManagerTest, SwitchFromOnDiskToInMemoryRestartsTypes) {
// Associate model with two data types. // Initialize the manager with two data types.
controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>( controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(
BOOKMARKS, /*enable_transport_only_model=*/true); BOOKMARKS, /*enable_transport_only_model=*/true);
controllers_[APPS] = std::make_unique<FakeDataTypeController>( controllers_[APPS] = std::make_unique<FakeDataTypeController>(
...@@ -451,7 +450,7 @@ TEST_F(SyncModelLoadManagerTest, SwitchFromOnDiskToInMemoryRestartsTypes) { ...@@ -451,7 +450,7 @@ TEST_F(SyncModelLoadManagerTest, SwitchFromOnDiskToInMemoryRestartsTypes) {
TEST_F(SyncModelLoadManagerTest, TEST_F(SyncModelLoadManagerTest,
SwitchFromTransportOnlyToFullSyncRestartsTypes) { SwitchFromTransportOnlyToFullSyncRestartsTypes) {
// Associate model with two data types. // Initialize the manager with two data types.
controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>( controllers_[BOOKMARKS] = std::make_unique<FakeDataTypeController>(
BOOKMARKS, /*enable_transport_only_model=*/true); BOOKMARKS, /*enable_transport_only_model=*/true);
controllers_[APPS] = std::make_unique<FakeDataTypeController>( controllers_[APPS] = std::make_unique<FakeDataTypeController>(
......
...@@ -26,8 +26,8 @@ struct DataTypeConfigurationStats { ...@@ -26,8 +26,8 @@ struct DataTypeConfigurationStats {
// Time spent on downloading data for first-sync data types. // Time spent on downloading data for first-sync data types.
base::TimeDelta download_time; base::TimeDelta download_time;
// Waiting time for association of higher priority types to finish before // TODO(crbug.com/1102837): The concept of "association" doesn't exist
// asking association manager to associate. // anymore, and this is effectively always zero now. Get rid of it.
base::TimeDelta association_wait_time_for_high_priority; base::TimeDelta association_wait_time_for_high_priority;
// Types configured before this type. // Types configured before this type.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment