diff options
author | petewil@chromium.org <petewil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-03 03:22:15 +0000 |
---|---|---|
committer | petewil@chromium.org <petewil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-03 03:22:15 +0000 |
commit | a987e6153641b0463a3fa6fca129b227c4f29e71 (patch) | |
tree | da53e4795de09fac8e5d57dbfed5be682c7127a0 /sync | |
parent | 1859cbb22110aadf306c1f832aee7b350faada59 (diff) | |
download | chromium_src-a987e6153641b0463a3fa6fca129b227c4f29e71.zip chromium_src-a987e6153641b0463a3fa6fca129b227c4f29e71.tar.gz chromium_src-a987e6153641b0463a3fa6fca129b227c4f29e71.tar.bz2 |
Create a fresh sync datatype for Synced Notifications
BUG=164313
Review URL: https://chromiumcodereview.appspot.com/11441005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/internal_api/public/base/model_type.h | 4 | ||||
-rw-r--r-- | sync/protocol/nigori_specifics.proto | 2 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.cc | 12 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.h | 5 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions_unittest.cc | 7 | ||||
-rw-r--r-- | sync/protocol/sync.proto | 2 | ||||
-rw-r--r-- | sync/protocol/sync_proto.gyp | 1 | ||||
-rw-r--r-- | sync/protocol/synced_notification_specifics.proto | 20 | ||||
-rw-r--r-- | sync/syncable/model_type.cc | 21 | ||||
-rw-r--r-- | sync/util/data_type_histogram.h | 3 |
10 files changed, 75 insertions, 2 deletions
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h index f24e61d..c0ac0ed 100644 --- a/sync/internal_api/public/base/model_type.h +++ b/sync/internal_api/public/base/model_type.h @@ -83,7 +83,9 @@ enum ModelType { APP_NOTIFICATIONS, // History delete directives. HISTORY_DELETE_DIRECTIVES, - LAST_USER_MODEL_TYPE = HISTORY_DELETE_DIRECTIVES, + // Synced push notifications. + SYNCED_NOTIFICATIONS, + LAST_USER_MODEL_TYPE = SYNCED_NOTIFICATIONS, // An object representing a set of Nigori keys. NIGORI, diff --git a/sync/protocol/nigori_specifics.proto b/sync/protocol/nigori_specifics.proto index c904783..e591408 100644 --- a/sync/protocol/nigori_specifics.proto +++ b/sync/protocol/nigori_specifics.proto @@ -53,6 +53,8 @@ message NigoriSpecifics { // Passwords are always encrypted, so we don't need a field here. // History delete directives need to be consumable by the server, and // thus can't be encrypted. + // Synced Notifications need to be consumed by the server (the read flag) + // and thus can't be encrypted. optional bool encrypt_bookmarks = 13; optional bool encrypt_preferences = 14; optional bool encrypt_autofill_profile = 15; diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index 320ef27..bc486e9 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -28,6 +28,7 @@ #include "sync/protocol/search_engine_specifics.pb.h" #include "sync/protocol/session_specifics.pb.h" #include "sync/protocol/sync.pb.h" +#include "sync/protocol/synced_notification_specifics.pb.h" #include "sync/protocol/theme_specifics.pb.h" #include "sync/protocol/typed_url_specifics.pb.h" @@ -220,6 +221,9 @@ base::DictionaryValue* TimeRangeDirectiveToValue( return value; } +// TODO(petewil): I will need new functions here for the SyncedNotifications +// subtypes. + DictionaryValue* AppNotificationToValue( const sync_pb::AppNotification& proto) { DictionaryValue* value = new DictionaryValue(); @@ -383,6 +387,13 @@ DictionaryValue* PreferenceSpecificsToValue( return value; } +DictionaryValue* SyncedNotificationSpecificsToValue( + const sync_pb::SyncedNotificationSpecifics& proto) { + DictionaryValue* value = new DictionaryValue(); + // TODO(petewil): Adjust this once we add actual types in protobuf. + return value; +} + DictionaryValue* SearchEngineSpecificsToValue( const sync_pb::SearchEngineSpecifics& proto) { DictionaryValue* value = new DictionaryValue(); @@ -456,6 +467,7 @@ DictionaryValue* EntitySpecificsToValue( SET_FIELD(preference, PreferenceSpecificsToValue); SET_FIELD(search_engine, SearchEngineSpecificsToValue); SET_FIELD(session, SessionSpecificsToValue); + SET_FIELD(synced_notification, SyncedNotificationSpecificsToValue); SET_FIELD(theme, ThemeSpecificsToValue); SET_FIELD(typed_url, TypedUrlSpecificsToValue); return value; diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h index 5c150ce..a553e56 100644 --- a/sync/protocol/proto_value_conversions.h +++ b/sync/protocol/proto_value_conversions.h @@ -49,6 +49,7 @@ class SessionSpecifics; class SessionTab; class SessionWindow; class SyncCycleCompletedEventInfo; +class SyncedNotificationSpecifics; class TabNavigation; class ThemeSpecifics; class TimeRangeDirective; @@ -159,6 +160,10 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsToValue( SYNC_EXPORT_PRIVATE base::DictionaryValue* PreferenceSpecificsToValue( const sync_pb::PreferenceSpecifics& password_specifics); +SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationSpecificsToValue( + const sync_pb::SyncedNotificationSpecifics& + synced_notification_specifics); + SYNC_EXPORT_PRIVATE base::DictionaryValue* SearchEngineSpecificsToValue( const sync_pb::SearchEngineSpecifics& search_engine_specifics); diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index 642037c..bc4e652 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -49,7 +49,7 @@ TEST_F(ProtoValueConversionsTest, ProtoChangeCheck) { // If this number changes, that means we added or removed a data // type. Don't forget to add a unit test for {New // type}SpecificsToValue below. - EXPECT_EQ(20, MODEL_TYPE_COUNT); + EXPECT_EQ(21, MODEL_TYPE_COUNT); // We'd also like to check if we changed any field in our messages. // However, that's hard to do: sizeof could work, but it's @@ -178,6 +178,10 @@ TEST_F(ProtoValueConversionsTest, SessionSpecificsToValue) { TestSpecificsToValue(SessionSpecificsToValue); } +TEST_F(ProtoValueConversionsTest, SyncedNotificationSpecificsToValue) { + TestSpecificsToValue(SyncedNotificationSpecificsToValue); +} + TEST_F(ProtoValueConversionsTest, ThemeSpecificsToValue) { TestSpecificsToValue(ThemeSpecificsToValue); } @@ -210,6 +214,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { SET_FIELD(preference); SET_FIELD(search_engine); SET_FIELD(session); + SET_FIELD(synced_notification); SET_FIELD(theme); SET_FIELD(typed_url); diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index ba01725..f8bdd02 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -34,6 +34,7 @@ import "preference_specifics.proto"; import "search_engine_specifics.proto"; import "session_specifics.proto"; import "sync_enums.proto"; +import "synced_notification_specifics.proto"; import "theme_specifics.proto"; import "typed_url_specifics.proto"; @@ -101,6 +102,7 @@ message EntitySpecifics { optional ExtensionSettingSpecifics extension_setting = 96159; optional AppSettingSpecifics app_setting = 103656; optional HistoryDeleteDirectiveSpecifics history_delete_directive = 150251; + optional SyncedNotificationSpecifics synced_notification = 153108; optional DeviceInfoSpecifics device_info = 154522; optional ExperimentsSpecifics experiments = 161496; } diff --git a/sync/protocol/sync_proto.gyp b/sync/protocol/sync_proto.gyp index 295e329..8f890f6 100644 --- a/sync/protocol/sync_proto.gyp +++ b/sync/protocol/sync_proto.gyp @@ -32,6 +32,7 @@ 'session_specifics.proto', 'sync.proto', 'sync_enums.proto', + 'synced_notification_specifics.proto', 'test.proto', 'theme_specifics.proto', 'typed_url_specifics.proto', diff --git a/sync/protocol/synced_notification_specifics.proto b/sync/protocol/synced_notification_specifics.proto new file mode 100644 index 0000000..db82f52 --- /dev/null +++ b/sync/protocol/synced_notification_specifics.proto @@ -0,0 +1,20 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Sync protocol datatype extension for synced notifications. + +// Update proto_value_conversions{.h,.cc,_unittest.cc} if you change +// any fields in this file. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +// Properties of SyncedNotificationSpecifics objects. +message SyncedNotificationSpecifics { + // TODO(petewil): this is placeholder data, make a real one +} diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc index ca9c3e7..a6ee409 100644 --- a/sync/syncable/model_type.cc +++ b/sync/syncable/model_type.cc @@ -76,6 +76,9 @@ void AddDefaultFieldValue(ModelType datatype, case HISTORY_DELETE_DIRECTIVES: specifics->mutable_history_delete_directive(); break; + case SYNCED_NOTIFICATIONS: + specifics->mutable_synced_notification(); + break; case DEVICE_INFO: specifics->mutable_device_info(); break; @@ -145,6 +148,8 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) { break; case HISTORY_DELETE_DIRECTIVES: return sync_pb::EntitySpecifics::kHistoryDeleteDirectiveFieldNumber; + case SYNCED_NOTIFICATIONS: + return sync_pb::EntitySpecifics::kSyncedNotificationFieldNumber; case DEVICE_INFO: return sync_pb::EntitySpecifics::kDeviceInfoFieldNumber; break; @@ -246,6 +251,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { if (specifics.has_history_delete_directive()) return HISTORY_DELETE_DIRECTIVES; + if (specifics.has_synced_notification()) + return SYNCED_NOTIFICATIONS; + if (specifics.has_device_info()) return DEVICE_INFO; @@ -271,6 +279,8 @@ ModelTypeSet EncryptableUserTypes() { ModelTypeSet encryptable_user_types = UserTypes(); // We never encrypt history delete directives. encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); + // Synced notifications are not encrypted since the server must see changes. + encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); return encryptable_user_types; } @@ -328,6 +338,8 @@ const char* ModelTypeToString(ModelType model_type) { return "App Notifications"; case HISTORY_DELETE_DIRECTIVES: return "History Delete Directives"; + case SYNCED_NOTIFICATIONS: + return "Synced Notifications"; case DEVICE_INFO: return "Device Info"; case EXPERIMENTS: @@ -399,6 +411,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) { return APP_NOTIFICATIONS; else if (model_type_string == "History Delete Directives") return HISTORY_DELETE_DIRECTIVES; + else if (model_type_string == "Synced Notifications") + return SYNCED_NOTIFICATIONS; else if (model_type_string == "Device Info") return DEVICE_INFO; else if (model_type_string == "Experiments") @@ -473,6 +487,8 @@ std::string ModelTypeToRootTag(ModelType type) { return "google_chrome_app_notifications"; case HISTORY_DELETE_DIRECTIVES: return "google_chrome_history_delete_directives"; + case SYNCED_NOTIFICATIONS: + return "google_chrome_synced_notifications"; case DEVICE_INFO: return "google_chrome_device_info"; case EXPERIMENTS: @@ -504,6 +520,7 @@ const char kAutofillProfileNotificationType[] = "AUTOFILL_PROFILE"; const char kAppNotificationNotificationType[] = "APP_NOTIFICATION"; const char kHistoryDeleteDirectiveNotificationType[] = "HISTORY_DELETE_DIRECTIVE"; +const char kSyncedNotificationType[] = "SYNCED_NOTIFICATION"; const char kDeviceInfoNotificationType[] = "DEVICE_INFO"; const char kExperimentsNotificationType[] = "EXPERIMENTS"; } // namespace @@ -558,6 +575,8 @@ bool RealModelTypeToNotificationType(ModelType model_type, return true; case HISTORY_DELETE_DIRECTIVES: *notification_type = kHistoryDeleteDirectiveNotificationType; + case SYNCED_NOTIFICATIONS: + *notification_type = kSyncedNotificationType; case DEVICE_INFO: *notification_type = kDeviceInfoNotificationType; return true; @@ -620,6 +639,8 @@ bool NotificationTypeToRealModelType(const std::string& notification_type, return true; } else if (notification_type == kHistoryDeleteDirectiveNotificationType) { *model_type = HISTORY_DELETE_DIRECTIVES; + } else if (notification_type == kSyncedNotificationType) { + *model_type = SYNCED_NOTIFICATIONS; } else if (notification_type == kDeviceInfoNotificationType) { *model_type = DEVICE_INFO;; return true; diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h index d815ab5..790c4fe 100644 --- a/sync/util/data_type_histogram.h +++ b/sync/util/data_type_histogram.h @@ -84,6 +84,9 @@ case ::syncer::HISTORY_DELETE_DIRECTIVES: \ PER_DATA_TYPE_MACRO("HistoryDeleteDirectives"); \ break; \ + case ::syncer::SYNCED_NOTIFICATIONS: \ + PER_DATA_TYPE_MACRO("SyncedNotifications"); \ + break; \ case ::syncer::DEVICE_INFO: \ PER_DATA_TYPE_MACRO("DeviceInfo"); \ break; \ |