Commit 92b21f8a authored by zea's avatar zea Committed by Commit bot

[Sync] Have configuration specify which datatypes are ready to sync

In preparation for performing model association while other types are downloading,
the BackendDataTypeConfigurer::ConfigureDataTypes method will now return those
types that are ready to sync without further intervention from sync. These are the
types that were already syncing previously, and therefore don't need to be
downloaded or purged.

A followup patch will add the association logic and tests.

BUG=477063

Review URL: https://codereview.chromium.org/1081413003

Cr-Commit-Position: refs/heads/master@{#325582}
parent 5e41d3df
...@@ -133,7 +133,10 @@ class SyncBackendHost : public sync_driver::BackendDataTypeConfigurer { ...@@ -133,7 +133,10 @@ class SyncBackendHost : public sync_driver::BackendDataTypeConfigurer {
// The ready_task will be run when configuration is done with the // The ready_task will be run when configuration is done with the
// set of all types that failed configuration (i.e., if its argument // set of all types that failed configuration (i.e., if its argument
// is non-empty, then an error was encountered). // is non-empty, then an error was encountered).
void ConfigureDataTypes( // Returns the set of types that are ready to start without needing any
// further sync activity.
// BackendDataTypeConfigurer implementation.
syncer::ModelTypeSet ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
......
...@@ -324,11 +324,11 @@ void SyncBackendHostImpl::UnregisterInvalidationIds() { ...@@ -324,11 +324,11 @@ void SyncBackendHostImpl::UnregisterInvalidationIds() {
} }
} }
void SyncBackendHostImpl::ConfigureDataTypes( syncer::ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet, const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
syncer::ModelTypeSet)>& ready_task, ready_task,
const base::Callback<void()>& retry_callback) { const base::Callback<void()>& retry_callback) {
// Only one configure is allowed at a time. This is guaranteed by our // Only one configure is allowed at a time. This is guaranteed by our
// callers. The SyncBackendHostImpl requests one configure as the backend is // callers. The SyncBackendHostImpl requests one configure as the backend is
...@@ -445,6 +445,12 @@ void SyncBackendHostImpl::ConfigureDataTypes( ...@@ -445,6 +445,12 @@ void SyncBackendHostImpl::ConfigureDataTypes(
routing_info, routing_info,
ready_task, ready_task,
retry_callback); retry_callback);
DCHECK(syncer::Intersection(active_types, types_to_purge).Empty());
DCHECK(syncer::Intersection(active_types, fatal_types).Empty());
DCHECK(syncer::Intersection(active_types, unapply_types).Empty());
DCHECK(syncer::Intersection(active_types, inactive_types).Empty());
return syncer::Difference(active_types, types_to_download);
} }
void SyncBackendHostImpl::EnableEncryptEverything() { void SyncBackendHostImpl::EnableEncryptEverything() {
......
...@@ -100,7 +100,7 @@ class SyncBackendHostImpl ...@@ -100,7 +100,7 @@ class SyncBackendHostImpl
void StopSyncingForShutdown() override; void StopSyncingForShutdown() override;
scoped_ptr<base::Thread> Shutdown(syncer::ShutdownReason reason) override; scoped_ptr<base::Thread> Shutdown(syncer::ShutdownReason reason) override;
void UnregisterInvalidationIds() override; void UnregisterInvalidationIds() override;
void ConfigureDataTypes( syncer::ModelTypeSet ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
......
...@@ -55,12 +55,14 @@ scoped_ptr<base::Thread> SyncBackendHostMock::Shutdown( ...@@ -55,12 +55,14 @@ scoped_ptr<base::Thread> SyncBackendHostMock::Shutdown(
void SyncBackendHostMock::UnregisterInvalidationIds() {} void SyncBackendHostMock::UnregisterInvalidationIds() {}
void SyncBackendHostMock::ConfigureDataTypes( syncer::ModelTypeSet SyncBackendHostMock::ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet, const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
syncer::ModelTypeSet)>& ready_task, ready_task,
const base::Callback<void()>& retry_callback) {} const base::Callback<void()>& retry_callback) {
return syncer::ModelTypeSet();
}
void SyncBackendHostMock::EnableEncryptEverything() {} void SyncBackendHostMock::EnableEncryptEverything() {}
......
...@@ -53,7 +53,7 @@ class SyncBackendHostMock : public SyncBackendHost { ...@@ -53,7 +53,7 @@ class SyncBackendHostMock : public SyncBackendHost {
void UnregisterInvalidationIds() override; void UnregisterInvalidationIds() override;
void ConfigureDataTypes( syncer::ModelTypeSet ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
......
...@@ -42,17 +42,19 @@ class BackendDataTypeConfigurer { ...@@ -42,17 +42,19 @@ class BackendDataTypeConfigurer {
// is called when configuration is done with the set of data types // is called when configuration is done with the set of data types
// that succeeded/failed configuration (i.e., configuration succeeded iff // that succeeded/failed configuration (i.e., configuration succeeded iff
// the failed set is empty). // the failed set is empty).
// Returns: the set of types that are already configured and are ready to
// start.
// //
// TODO(akalin): Use a Delegate class with // TODO(akalin): Use a Delegate class with
// OnConfigureSuccess/OnConfigureFailure/OnConfigureRetry instead of // OnConfigureSuccess/OnConfigureFailure/OnConfigureRetry instead of
// a pair of callbacks. The awkward part is handling when // a pair of callbacks. The awkward part is handling when
// SyncBackendHost calls ConfigureDataTypes on itself to configure // SyncBackendHost calls ConfigureDataTypes on itself to configure
// Nigori. // Nigori.
virtual void ConfigureDataTypes( virtual syncer::ModelTypeSet ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(syncer::ModelTypeSet, const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
syncer::ModelTypeSet)>& ready_task, ready_task,
const base::Callback<void()>& retry_callback) = 0; const base::Callback<void()>& retry_callback) = 0;
// Return model types in |state_map| that match |state|. // Return model types in |state_map| that match |state|.
......
...@@ -82,7 +82,7 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer { ...@@ -82,7 +82,7 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
FakeBackendDataTypeConfigurer() {} FakeBackendDataTypeConfigurer() {}
~FakeBackendDataTypeConfigurer() override {} ~FakeBackendDataTypeConfigurer() override {}
void ConfigureDataTypes( syncer::ModelTypeSet ConfigureDataTypes(
syncer::ConfigureReason reason, syncer::ConfigureReason reason,
const DataTypeConfigStateMap& config_state_map, const DataTypeConfigStateMap& config_state_map,
const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
...@@ -98,6 +98,7 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer { ...@@ -98,6 +98,7 @@ class FakeBackendDataTypeConfigurer : public BackendDataTypeConfigurer {
<< ModelTypeSetToString( << ModelTypeSetToString(
GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map)); GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map));
} }
return syncer::ModelTypeSet();
} }
void ActivateDataType(syncer::ModelType type, void ActivateDataType(syncer::ModelType 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