Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4721)

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 312163004: [Sync] Add support for dynamically enabling/disabling types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 7ffece2f006789eaf7ec759b6baf71deac1d7ba4..4755685bb79b91712a6830ce6b2ad5ff46d1aacb 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -957,7 +957,7 @@ void ProfileSyncService::OnUnrecoverableErrorImpl(
}
// TODO(zea): Move this logic into the DataTypeController/DataTypeManager.
-void ProfileSyncService::DisableBrokenDatatype(
+void ProfileSyncService::DisableDatatype(
syncer::ModelType type,
const tracked_objects::Location& from_here,
std::string message) {
@@ -982,6 +982,24 @@ void ProfileSyncService::DisableBrokenDatatype(
weak_factory_.GetWeakPtr()));
}
+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()));
+}
+
void ProfileSyncService::UpdateBackendInitUMA(bool success) {
if (backend_mode_ != SYNC)
return;
@@ -1357,9 +1375,9 @@ void ProfileSyncService::OnEncryptedTypesChanged(
// delete directives are unnecessary.
if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
encrypted_types_.Has(syncer::SESSIONS)) {
- DisableBrokenDatatype(syncer::HISTORY_DELETE_DIRECTIVES,
- FROM_HERE,
- "Delete directives not supported with encryption.");
+ DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES,
+ FROM_HERE,
+ "Delete directives not supported with encryption.");
}
}
@@ -1763,9 +1781,9 @@ void ProfileSyncService::OnUserChoseDatatypes(
failed_data_types_handler_.Reset();
if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
encrypted_types_.Has(syncer::SESSIONS)) {
- DisableBrokenDatatype(syncer::HISTORY_DELETE_DIRECTIVES,
- FROM_HERE,
- "Delete directives not supported with encryption.");
+ DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES,
+ FROM_HERE,
+ "Delete directives not supported with encryption.");
}
ChangePreferredDataTypes(chosen_types);
AcknowledgeSyncedTypes();

Powered by Google App Engine
This is Rietveld 408576698