summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/sync/profile_sync_service.cc17
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc1
-rw-r--r--components/sync_driver/data_type_manager.h4
-rw-r--r--components/sync_driver/data_type_manager_impl.cc20
-rw-r--r--components/sync_driver/data_type_manager_impl.h1
-rw-r--r--components/sync_driver/data_type_manager_impl_unittest.cc15
-rw-r--r--components/sync_driver/data_type_manager_mock.h1
-rw-r--r--sync/engine/get_updates_delegate.cc2
-rw-r--r--sync/engine/sync_scheduler_impl.cc1
-rw-r--r--sync/internal_api/public/configure_reason.h4
-rw-r--r--sync/internal_api/sync_manager_impl.cc2
-rw-r--r--sync/protocol/get_updates_caller_info.proto2
-rw-r--r--sync/protocol/proto_enum_conversions.cc6
-rw-r--r--sync/protocol/sync_enums.proto2
14 files changed, 55 insertions, 23 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index d46a0e7..45e1c1d 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -1008,21 +1008,8 @@ void ProfileSyncService::OnUnrecoverableErrorImpl(
}
void ProfileSyncService::ReenableDatatype(syncer::ModelType type) {
- // Only reconfigure if the type actually had a data type or unready error.
- if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) &&
- !failed_data_types_handler_.ResetUnreadyErrorFor(type)) {
- return;
- }
-
- // If the type is no longer enabled, don't bother reconfiguring.
- // TODO(zea): something else should encapsulate the notion of "whether a type
- // should be enabled".
- if (!syncer::CoreTypes().Has(type) && !GetPreferredDataTypes().Has(type))
- return;
-
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&ProfileSyncService::ReconfigureDatatypeManager,
- weak_factory_.GetWeakPtr()));
+ DCHECK(backend_initialized_);
+ directory_data_type_manager_->ReenableType(type);
}
void ProfileSyncService::UpdateBackendInitUMA(bool success) {
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index 3a0773b..c1496be 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -57,6 +57,7 @@ class FakeDataTypeManager : public sync_driver::DataTypeManager {
observer_->OnConfigureDone(result);
}
+ virtual void ReenableType(syncer::ModelType type) OVERRIDE {}
virtual void PurgeForMigration(syncer::ModelTypeSet undesired_types,
syncer::ConfigureReason reason) OVERRIDE {}
virtual void Stop() OVERRIDE {};
diff --git a/components/sync_driver/data_type_manager.h b/components/sync_driver/data_type_manager.h
index 6ea5254..e4657b6 100644
--- a/components/sync_driver/data_type_manager.h
+++ b/components/sync_driver/data_type_manager.h
@@ -74,6 +74,10 @@ class DataTypeManager {
virtual void Configure(syncer::ModelTypeSet desired_types,
syncer::ConfigureReason reason) = 0;
+ // Resets the error state for |type| and triggers a reconfiguration if
+ // necessary.
+ virtual void ReenableType(syncer::ModelType type) = 0;
+
virtual void PurgeForMigration(syncer::ModelTypeSet undesired_types,
syncer::ConfigureReason reason) = 0;
diff --git a/components/sync_driver/data_type_manager_impl.cc b/components/sync_driver/data_type_manager_impl.cc
index 77545aa..936a745 100644
--- a/components/sync_driver/data_type_manager_impl.cc
+++ b/components/sync_driver/data_type_manager_impl.cc
@@ -111,6 +111,25 @@ void DataTypeManagerImpl::Configure(syncer::ModelTypeSet desired_types,
ConfigureImpl(filtered_desired_types, reason);
}
+void DataTypeManagerImpl::ReenableType(syncer::ModelType type) {
+ // TODO(zea): move the "should we reconfigure" logic into the datatype handler
+ // itself.
+ // Only reconfigure if the type actually had a data type or unready error.
+ if (!failed_data_types_handler_->ResetDataTypeErrorFor(type) &&
+ !failed_data_types_handler_->ResetUnreadyErrorFor(type)) {
+ return;
+ }
+
+ // Only reconfigure if the type is actually desired.
+ if (!last_requested_types_.Has(type))
+ return;
+
+ DVLOG(1) << "Reenabling " << syncer::ModelTypeToString(type);
+ needs_reconfigure_ = true;
+ last_configure_reason_ = syncer::CONFIGURE_REASON_PROGRAMMATIC;
+ ProcessReconfigure();
+}
+
void DataTypeManagerImpl::PurgeForMigration(
syncer::ModelTypeSet undesired_types,
syncer::ConfigureReason reason) {
@@ -419,6 +438,7 @@ void DataTypeManagerImpl::OnSingleDataTypeWillStop(
// reconfigure.
if (error.error_type() != syncer::SyncError::UNRECOVERABLE_ERROR) {
needs_reconfigure_ = true;
+ last_configure_reason_ = syncer::CONFIGURE_REASON_PROGRAMMATIC;
ProcessReconfigure();
} else {
DCHECK_EQ(state_, CONFIGURING);
diff --git a/components/sync_driver/data_type_manager_impl.h b/components/sync_driver/data_type_manager_impl.h
index 84f96a8..8d42ea8 100644
--- a/components/sync_driver/data_type_manager_impl.h
+++ b/components/sync_driver/data_type_manager_impl.h
@@ -53,6 +53,7 @@ class DataTypeManagerImpl : public DataTypeManager,
// DataTypeManager interface.
virtual void Configure(syncer::ModelTypeSet desired_types,
syncer::ConfigureReason reason) OVERRIDE;
+ virtual void ReenableType(syncer::ModelType type) OVERRIDE;
// Needed only for backend migration.
virtual void PurgeForMigration(
diff --git a/components/sync_driver/data_type_manager_impl_unittest.cc b/components/sync_driver/data_type_manager_impl_unittest.cc
index de5855b..80edbe0 100644
--- a/components/sync_driver/data_type_manager_impl_unittest.cc
+++ b/components/sync_driver/data_type_manager_impl_unittest.cc
@@ -1180,12 +1180,9 @@ TEST_F(SyncDataTypeManagerImplTest, ReenableAfterDataTypeError) {
Mock::VerifyAndClearExpectations(&observer_);
// Re-enable bookmarks.
- failed_data_types_handler_.ResetDataTypeErrorFor(syncer::BOOKMARKS);
-
- SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK);
+ dtm_->ReenableType(syncer::BOOKMARKS);
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS, PREFERENCES));
EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
FinishDownload(*dtm_, ModelTypeSet(BOOKMARKS), ModelTypeSet());
@@ -1194,6 +1191,9 @@ TEST_F(SyncDataTypeManagerImplTest, ReenableAfterDataTypeError) {
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(DataTypeController::RUNNING, GetController(PREFERENCES)->state());
EXPECT_EQ(DataTypeController::RUNNING, GetController(BOOKMARKS)->state());
+
+ // Should do nothing.
+ dtm_->ReenableType(syncer::BOOKMARKS);
}
TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
@@ -1212,9 +1212,8 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
// Bookmarks should start normally now.
GetController(BOOKMARKS)->SetReadyForStart(true);
- SetConfigureStartExpectation();
SetConfigureDoneExpectation(DataTypeManager::OK);
- Configure(dtm_.get(), ModelTypeSet(BOOKMARKS));
+ dtm_->ReenableType(BOOKMARKS);
EXPECT_EQ(DataTypeManager::DOWNLOAD_PENDING, dtm_->state());
FinishDownload(*dtm_, ModelTypeSet(), ModelTypeSet());
@@ -1225,6 +1224,10 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyType) {
EXPECT_EQ(DataTypeManager::CONFIGURED, dtm_->state());
EXPECT_EQ(1U, configurer_.activated_types().Size());
+ // Should do nothing.
+ Mock::VerifyAndClearExpectations(&observer_);
+ dtm_->ReenableType(BOOKMARKS);
+
dtm_->Stop();
EXPECT_EQ(DataTypeManager::STOPPED, dtm_->state());
EXPECT_TRUE(configurer_.activated_types().Empty());
diff --git a/components/sync_driver/data_type_manager_mock.h b/components/sync_driver/data_type_manager_mock.h
index 50c4fe0..fac6522 100644
--- a/components/sync_driver/data_type_manager_mock.h
+++ b/components/sync_driver/data_type_manager_mock.h
@@ -17,6 +17,7 @@ class DataTypeManagerMock : public DataTypeManager {
virtual ~DataTypeManagerMock();
MOCK_METHOD2(Configure, void(syncer::ModelTypeSet, syncer::ConfigureReason));
+ MOCK_METHOD1(ReenableType, void(syncer::ModelType));
MOCK_METHOD2(PurgeForMigration, void(syncer::ModelTypeSet,
syncer::ConfigureReason));
MOCK_METHOD0(Stop, void());
diff --git a/sync/engine/get_updates_delegate.cc b/sync/engine/get_updates_delegate.cc
index ac66eef..af4ad57 100644
--- a/sync/engine/get_updates_delegate.cc
+++ b/sync/engine/get_updates_delegate.cc
@@ -136,6 +136,8 @@ ConfigureGetUpdatesDelegate::ConvertConfigureSourceToOrigin(
return sync_pb::SyncEnums::RECONFIGURATION;
case sync_pb::GetUpdatesCallerInfo::NEW_CLIENT:
return sync_pb::SyncEnums::NEW_CLIENT;
+ case sync_pb::GetUpdatesCallerInfo::PROGRAMMATIC:
+ return sync_pb::SyncEnums::PROGRAMMATIC;
default:
NOTREACHED();
return sync_pb::SyncEnums::UNKNOWN_ORIGIN;
diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc
index 974ed27..7b07815 100644
--- a/sync/engine/sync_scheduler_impl.cc
+++ b/sync/engine/sync_scheduler_impl.cc
@@ -143,6 +143,7 @@ bool IsConfigRelatedUpdateSourceValue(
case GetUpdatesCallerInfo::MIGRATION:
case GetUpdatesCallerInfo::NEW_CLIENT:
case GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE:
+ case GetUpdatesCallerInfo::PROGRAMMATIC:
return true;
default:
return false;
diff --git a/sync/internal_api/public/configure_reason.h b/sync/internal_api/public/configure_reason.h
index 43784b7..6dadeff 100644
--- a/sync/internal_api/public/configure_reason.h
+++ b/sync/internal_api/public/configure_reason.h
@@ -35,6 +35,10 @@ enum ConfigureReason {
// Configure data types for backup/rollback.
CONFIGURE_REASON_BACKUP_ROLLBACK,
+
+ // The client is configuring because of a programmatic type enable/disable,
+ // such as when an error is encountered/resolved.
+ CONFIGURE_REASON_PROGRAMMATIC,
};
} // namespace syncer
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 8d2c8e2..a444b91 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -79,6 +79,8 @@ GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason(
case CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE:
case CONFIGURE_REASON_CRYPTO:
return GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE;
+ case CONFIGURE_REASON_PROGRAMMATIC:
+ return GetUpdatesCallerInfo::PROGRAMMATIC;
default:
NOTREACHED();
}
diff --git a/sync/protocol/get_updates_caller_info.proto b/sync/protocol/get_updates_caller_info.proto
index ce37e61..118cce8 100644
--- a/sync/protocol/get_updates_caller_info.proto
+++ b/sync/protocol/get_updates_caller_info.proto
@@ -43,6 +43,8 @@ message GetUpdatesCallerInfo {
// typically used when datatype's have custom
// sync UI, e.g. sessions.
RETRY = 13; // A follow-up GU to pick up updates missed by previous GU.
+ PROGRAMMATIC = 14; // The client is programmatically enabling/disabling
+ // a type, typically for error handling purposes.
}
required GetUpdatesSource source = 1;
diff --git a/sync/protocol/proto_enum_conversions.cc b/sync/protocol/proto_enum_conversions.cc
index 213a096..4c43983 100644
--- a/sync/protocol/proto_enum_conversions.cc
+++ b/sync/protocol/proto_enum_conversions.cc
@@ -83,7 +83,7 @@ const char* GetPageTransitionRedirectTypeString(
const char* GetUpdatesSourceString(
sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source) {
ASSERT_ENUM_BOUNDS(sync_pb::GetUpdatesCallerInfo, GetUpdatesSource,
- UNKNOWN, RETRY);
+ UNKNOWN, PROGRAMMATIC);
switch (updates_source) {
ENUM_CASE(sync_pb::GetUpdatesCallerInfo, UNKNOWN);
ENUM_CASE(sync_pb::GetUpdatesCallerInfo, FIRST_UPDATE);
@@ -97,6 +97,7 @@ const char* GetUpdatesSourceString(
ENUM_CASE(sync_pb::GetUpdatesCallerInfo, RECONFIGURATION);
ENUM_CASE(sync_pb::GetUpdatesCallerInfo, DATATYPE_REFRESH);
ENUM_CASE(sync_pb::GetUpdatesCallerInfo, RETRY);
+ ENUM_CASE(sync_pb::GetUpdatesCallerInfo, PROGRAMMATIC);
}
NOTREACHED();
return "";
@@ -105,7 +106,7 @@ const char* GetUpdatesSourceString(
const char* GetUpdatesOriginString(
sync_pb::SyncEnums::GetUpdatesOrigin origin) {
ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, GetUpdatesOrigin,
- UNKNOWN_ORIGIN, RETRY);
+ UNKNOWN_ORIGIN, PROGRAMMATIC);
switch (origin) {
ENUM_CASE(sync_pb::SyncEnums, UNKNOWN_ORIGIN);
ENUM_CASE(sync_pb::SyncEnums, PERIODIC);
@@ -115,6 +116,7 @@ const char* GetUpdatesOriginString(
ENUM_CASE(sync_pb::SyncEnums, RECONFIGURATION);
ENUM_CASE(sync_pb::SyncEnums, GU_TRIGGER);
ENUM_CASE(sync_pb::SyncEnums, RETRY);
+ ENUM_CASE(sync_pb::SyncEnums, PROGRAMMATIC);
}
NOTREACHED();
return "";
diff --git a/sync/protocol/sync_enums.proto b/sync/protocol/sync_enums.proto
index 6e1405b..9ee2a9c 100644
--- a/sync/protocol/sync_enums.proto
+++ b/sync/protocol/sync_enums.proto
@@ -157,5 +157,7 @@ message SyncEnums {
// GetUpdateTriggers message for more details.
RETRY = 13; // A retry GU to pick up updates missed by last GU due to
// replication delay, missing hints, etc.
+ PROGRAMMATIC = 14; // A GU to programmatically enable/disable a
+ // datatype, often due to error handling.
}
}