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

Unified Diff: sync/syncable/model_type.cc

Issue 10825137: FYI: Control Data + Per-Device Metadata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add PER_USER_METADATA, refactor some encryption code Created 8 years, 4 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: sync/syncable/model_type.cc
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index 83e803cdd58c451f6b8eae1efa8e35e56e156203..2c725020964200dc1dff114aaa2e5ec3ada74968 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -73,6 +73,12 @@ void AddDefaultFieldValue(ModelType datatype,
case APP_NOTIFICATIONS:
specifics->mutable_app_notification();
break;
+ case PER_DEVICE_METADATA:
+ specifics->mutable_per_device_metadata();
+ break;
+ case PER_USER_METADATA:
+ specifics->mutable_per_user_metadata();
+ break;
default:
NOTREACHED() << "No known extension for model type.";
}
@@ -135,6 +141,12 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) {
case APP_NOTIFICATIONS:
return sync_pb::EntitySpecifics::kAppNotificationFieldNumber;
break;
+ case PER_DEVICE_METADATA:
+ return sync_pb::EntitySpecifics::kPerDeviceMetadataFieldNumber;
+ break;
+ case PER_USER_METADATA:
+ return sync_pb::EntitySpecifics::kPerUserMetadataFieldNumber;
+ break;
default:
NOTREACHED() << "No known extension for model type.";
return 0;
@@ -219,6 +231,12 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.has_app_notification())
return APP_NOTIFICATIONS;
+ if (specifics.has_per_device_metadata())
+ return PER_DEVICE_METADATA;
+
+ if (specifics.has_per_user_metadata())
+ return PER_USER_METADATA;
+
return UNSPECIFIED;
}
@@ -226,6 +244,23 @@ bool ShouldMaintainPosition(ModelType model_type) {
return model_type == BOOKMARKS;
}
+bool IsControlType(ModelType model_type) {
+ return ControlTypes().Has(model_type);
+}
+
+ModelTypeSet ControlTypes() {
+ ModelTypeSet set;
+ set.Put(NIGORI);
+ set.Put(PER_DEVICE_METADATA);
+ set.Put(PER_USER_METADATA);
+ return set;
+}
+
+ModelTypeSet EncryptableTypes() {
+ ModelTypeSet unencryptable_types(PER_DEVICE_METADATA, PER_USER_METADATA);
rlarocque 2012/08/11 01:31:52 Why do these types skip encryption? I believe the
+ return Difference(ModelTypeSet::All(), unencryptable_types);
+}
+
const char* ModelTypeToString(ModelType model_type) {
// This is used in serialization routines as well as for displaying debug
// information. Do not attempt to change these string values unless you know
@@ -265,6 +300,10 @@ const char* ModelTypeToString(ModelType model_type) {
return "Extension settings";
case APP_NOTIFICATIONS:
return "App Notifications";
+ case PER_DEVICE_METADATA:
+ return "Device Metadata";
+ case PER_USER_METADATA:
+ return "User Metadata";
default:
break;
}
@@ -330,6 +369,10 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return EXTENSION_SETTINGS;
else if (model_type_string == "App Notifications")
return APP_NOTIFICATIONS;
+ else if (model_type_string == "Device Metadata")
+ return PER_DEVICE_METADATA;
+ else if (model_type_string == "User Metadata")
+ return PER_USER_METADATA;
else
NOTREACHED() << "No known model type corresponding to "
<< model_type_string << ".";
@@ -398,6 +441,10 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_extension_settings";
case APP_NOTIFICATIONS:
return "google_chrome_app_notifications";
+ case PER_DEVICE_METADATA:
+ return "google_chrome_per_device_metadata";
+ case PER_USER_METADATA:
+ return "google_chrome_per_user_metadata";
default:
break;
}
@@ -423,6 +470,8 @@ const char kSearchEngineNotificationType[] = "SEARCH_ENGINE";
const char kSessionNotificationType[] = "SESSION";
const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE";
const char kAppNotificationNotificationType[] = "APP_NOTIFICATION";
+const char kPerDeviceNotificationType[] = "PER_DEVICE_METADATA";
+const char kPerUserNotificationType[] = "PER_USER_METADATA";
} // namespace
bool RealModelTypeToNotificationType(ModelType model_type,
@@ -473,6 +522,12 @@ bool RealModelTypeToNotificationType(ModelType model_type,
case APP_NOTIFICATIONS:
*notification_type = kAppNotificationNotificationType;
return true;
+ case PER_DEVICE_METADATA:
+ *notification_type = kPerDeviceNotificationType;
+ return true;
+ case PER_USER_METADATA:
+ *notification_type = kPerUserNotificationType;
+ return true;
default:
break;
}
@@ -527,6 +582,12 @@ bool NotificationTypeToRealModelType(const std::string& notification_type,
} else if (notification_type == kAppNotificationNotificationType) {
*model_type = APP_NOTIFICATIONS;
return true;
+ } else if (notification_type == kPerDeviceNotificationType) {
+ *model_type = PER_DEVICE_METADATA;;
+ return true;
+ } else if (notification_type == kPerUserNotificationType) {
+ *model_type = PER_USER_METADATA;;
+ return true;
} else {
*model_type = UNSPECIFIED;
return false;

Powered by Google App Engine
This is Rietveld 408576698