summaryrefslogtreecommitdiffstats
path: root/sync/syncable
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 04:01:39 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 04:01:39 +0000
commit34e98172346b0da9355a3a55189d8536adce649b (patch)
tree57d35504a96e41f384687a9a842c072686623f4e /sync/syncable
parent408b4837cc567d493ce78f931162e3d3bfd71540 (diff)
downloadchromium_src-34e98172346b0da9355a3a55189d8536adce649b.zip
chromium_src-34e98172346b0da9355a3a55189d8536adce649b.tar.gz
chromium_src-34e98172346b0da9355a3a55189d8536adce649b.tar.bz2
sync: Add DeviceInfo protobuf and supporting code
This commit introduces the DeviceInfo type and protobuf. It also introduces the DeviceInfo class, which provides an interface for the rest of the code to access the information stored within the DeviceInfo type. The DeviceInfo class takes over some functions that used to belong to the SessionModelAssociator. The ChangeProcessor that keeps this information up to date and exposes notifications of device info changes will be added in a future commit. At the time of this commit, this should all be mostly dead code. The server does not support this type yet, so we do not yet attempt to download or manipulate any actual DeviceInfo nodes. BUG=122825 Review URL: https://chromiumcodereview.appspot.com/10985008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/syncable')
-rw-r--r--sync/syncable/model_type.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index 1674206..e4993a4 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -73,6 +73,9 @@ void AddDefaultFieldValue(ModelType datatype,
case APP_NOTIFICATIONS:
specifics->mutable_app_notification();
break;
+ case DEVICE_INFO:
+ specifics->mutable_device_info();
+ break;
default:
NOTREACHED() << "No known extension for model type.";
}
@@ -135,6 +138,9 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) {
case APP_NOTIFICATIONS:
return sync_pb::EntitySpecifics::kAppNotificationFieldNumber;
break;
+ case DEVICE_INFO:
+ return sync_pb::EntitySpecifics::kDeviceInfoFieldNumber;
+ break;
default:
NOTREACHED() << "No known extension for model type.";
return 0;
@@ -227,6 +233,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.has_app_notification())
return APP_NOTIFICATIONS;
+ if (specifics.has_device_info())
+ return DEVICE_INFO;
+
return UNSPECIFIED;
}
@@ -247,6 +256,10 @@ ModelTypeSet ControlTypes() {
for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) {
set.Put(ModelTypeFromInt(i));
}
+
+ // TODO(rlarocque): Re-enable this when the server supports it.
+ set.Remove(DEVICE_INFO);
+
return set;
}
@@ -293,6 +306,8 @@ const char* ModelTypeToString(ModelType model_type) {
return "Extension settings";
case APP_NOTIFICATIONS:
return "App Notifications";
+ case DEVICE_INFO:
+ return "Device Info";
default:
break;
}
@@ -358,6 +373,8 @@ 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 Info")
+ return DEVICE_INFO;
else
NOTREACHED() << "No known model type corresponding to "
<< model_type_string << ".";
@@ -426,6 +443,8 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_extension_settings";
case APP_NOTIFICATIONS:
return "google_chrome_app_notifications";
+ case DEVICE_INFO:
+ return "google_chrome_device_info";
default:
break;
}
@@ -451,6 +470,7 @@ const char kSearchEngineNotificationType[] = "SEARCH_ENGINE";
const char kSessionNotificationType[] = "SESSION";
const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE";
const char kAppNotificationNotificationType[] = "APP_NOTIFICATION";
+const char kDeviceInfoNotificationType[] = "DEVICE_INFO";
} // namespace
bool RealModelTypeToNotificationType(ModelType model_type,
@@ -501,6 +521,9 @@ bool RealModelTypeToNotificationType(ModelType model_type,
case APP_NOTIFICATIONS:
*notification_type = kAppNotificationNotificationType;
return true;
+ case DEVICE_INFO:
+ *notification_type = kDeviceInfoNotificationType;
+ return true;
default:
break;
}
@@ -555,6 +578,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type,
} else if (notification_type == kAppNotificationNotificationType) {
*model_type = APP_NOTIFICATIONS;
return true;
+ } else if (notification_type == kDeviceInfoNotificationType) {
+ *model_type = DEVICE_INFO;;
+ return true;
} else {
*model_type = UNSPECIFIED;
return false;