diff options
Diffstat (limited to 'sync')
-rw-r--r-- | sync/internal_api/base_node.cc | 6 | ||||
-rw-r--r-- | sync/internal_api/public/base/model_type.h | 5 | ||||
-rw-r--r-- | sync/internal_api/public/base_node.h | 5 | ||||
-rw-r--r-- | sync/internal_api/public/write_node.h | 5 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl_unittest.cc | 3 | ||||
-rw-r--r-- | sync/internal_api/write_node.cc | 7 | ||||
-rw-r--r-- | sync/protocol/priority_preference_specifics.proto | 21 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.cc | 10 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.h | 4 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions_unittest.cc | 8 | ||||
-rw-r--r-- | sync/protocol/sync.proto | 2 | ||||
-rw-r--r-- | sync/protocol/sync_proto.gyp | 1 | ||||
-rw-r--r-- | sync/syncable/model_type.cc | 24 | ||||
-rw-r--r-- | sync/util/data_type_histogram.h | 3 |
14 files changed, 101 insertions, 3 deletions
diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc index f30c36e..4ae318b 100644 --- a/sync/internal_api/base_node.cc +++ b/sync/internal_api/base_node.cc @@ -343,6 +343,12 @@ const sync_pb::ExperimentsSpecifics& BaseNode::GetExperimentsSpecifics() const { return GetEntitySpecifics().experiments(); } +const sync_pb::PriorityPreferenceSpecifics& + BaseNode::GetPriorityPreferenceSpecifics() const { + DCHECK_EQ(GetModelType(), PRIORITY_PREFERENCES); + return GetEntitySpecifics().priority_preference(); +} + const sync_pb::EntitySpecifics& BaseNode::GetEntitySpecifics() const { return GetUnencryptedSpecifics(GetEntry()); } diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h index c0ac0ed..d8a5348 100644 --- a/sync/internal_api/public/base/model_type.h +++ b/sync/internal_api/public/base/model_type.h @@ -94,7 +94,10 @@ enum ModelType { DEVICE_INFO, // Flags to enable experimental features. EXPERIMENTS, - LAST_CONTROL_MODEL_TYPE = EXPERIMENTS, + // These preferences are never encrypted so that they can be applied before + // the encryption system is fully initialized. + PRIORITY_PREFERENCES, + LAST_CONTROL_MODEL_TYPE = PRIORITY_PREFERENCES, LAST_REAL_MODEL_TYPE = LAST_CONTROL_MODEL_TYPE, diff --git a/sync/internal_api/public/base_node.h b/sync/internal_api/public/base_node.h index b3946fb..3602923 100644 --- a/sync/internal_api/public/base_node.h +++ b/sync/internal_api/public/base_node.h @@ -161,6 +161,11 @@ class SYNC_EXPORT BaseNode { // data. Can only be called if GetModelType() == EXPERIMENTS. const sync_pb::ExperimentsSpecifics& GetExperimentsSpecifics() const; + // Getter specific to the PRIORITY_PREFERENCE datatype. Returns protobuf + // data. Can only be called if GetModelType() == PRIORITY_PREFERENCE. + const sync_pb::PriorityPreferenceSpecifics& + GetPriorityPreferenceSpecifics() const; + const sync_pb::EntitySpecifics& GetEntitySpecifics() const; // Returns the local external ID associated with the node. diff --git a/sync/internal_api/public/write_node.h b/sync/internal_api/public/write_node.h index 3d843a0..73baa6f 100644 --- a/sync/internal_api/public/write_node.h +++ b/sync/internal_api/public/write_node.h @@ -166,6 +166,11 @@ class SYNC_EXPORT WriteNode : public BaseNode { // Should only be called if GetModelType() == EXPERIMENTS. void SetExperimentsSpecifics(const sync_pb::ExperimentsSpecifics& specifics); + // Set the priority preference specifics. + // Should only be called if GetModelType() == PRIORITY_PREFERENCE. + void SetPriorityPreferenceSpecifics( + const sync_pb::PriorityPreferenceSpecifics& specifics); + // Implementation of BaseNode's abstract virtual accessors. virtual const syncable::Entry* GetEntry() const OVERRIDE; diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc index b4ca259..fd981f1 100644 --- a/sync/internal_api/sync_manager_impl_unittest.cc +++ b/sync/internal_api/sync_manager_impl_unittest.cc @@ -863,6 +863,7 @@ class SyncManagerTest : public testing::Test, (*out)[SESSIONS] = GROUP_PASSIVE; (*out)[PASSWORDS] = GROUP_PASSIVE; (*out)[PREFERENCES] = GROUP_PASSIVE; + (*out)[PRIORITY_PREFERENCES] = GROUP_PASSIVE; } virtual void OnChangesApplied( @@ -1247,7 +1248,7 @@ TEST_F(SyncManagerTest, GetChildNodeIds) { const ListValue* nodes = NULL; ASSERT_TRUE(return_args.Get().GetList(0, &nodes)); ASSERT_TRUE(nodes); - EXPECT_EQ(8u, nodes->GetSize()); + EXPECT_EQ(9u, nodes->GetSize()); } TEST_F(SyncManagerTest, GetChildNodeIdsFailure) { diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc index 2057c25..5628571 100644 --- a/sync/internal_api/write_node.cc +++ b/sync/internal_api/write_node.cc @@ -198,6 +198,13 @@ void WriteNode::SetExperimentsSpecifics( SetEntitySpecifics(entity_specifics); } +void WriteNode::SetPriorityPreferenceSpecifics( + const sync_pb::PriorityPreferenceSpecifics& new_value) { + sync_pb::EntitySpecifics entity_specifics; + entity_specifics.mutable_priority_preference()->CopyFrom(new_value); + SetEntitySpecifics(entity_specifics); +} + void WriteNode::SetEntitySpecifics( const sync_pb::EntitySpecifics& new_value) { ModelType new_specifics_type = diff --git a/sync/protocol/priority_preference_specifics.proto b/sync/protocol/priority_preference_specifics.proto new file mode 100644 index 0000000..e52e0be --- /dev/null +++ b/sync/protocol/priority_preference_specifics.proto @@ -0,0 +1,21 @@ +// 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 priority preferences. + +// 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 a synced priority preference. +message PriorityPreferenceSpecifics { + optional string name = 1; + optional string value = 2; +} diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index d72b6de..97a989d 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -24,6 +24,7 @@ #include "sync/protocol/nigori_specifics.pb.h" #include "sync/protocol/password_specifics.pb.h" #include "sync/protocol/preference_specifics.pb.h" +#include "sync/protocol/priority_preference_specifics.pb.h" #include "sync/protocol/proto_enum_conversions.h" #include "sync/protocol/search_engine_specifics.pb.h" #include "sync/protocol/session_specifics.pb.h" @@ -299,6 +300,14 @@ DictionaryValue* BookmarkSpecificsToValue( return value; } +DictionaryValue* PriorityPreferenceSpecificsToValue( + const sync_pb::PriorityPreferenceSpecifics& proto) { + DictionaryValue* value = new DictionaryValue(); + SET_STR(name); + SET_STR(value); + return value; +} + DictionaryValue* DeviceInfoSpecificsToValue( const sync_pb::DeviceInfoSpecifics& proto) { DictionaryValue* value = new DictionaryValue(); @@ -466,6 +475,7 @@ DictionaryValue* EntitySpecificsToValue( SET_FIELD(nigori, NigoriSpecificsToValue); SET_FIELD(password, PasswordSpecificsToValue); SET_FIELD(preference, PreferenceSpecificsToValue); + SET_FIELD(priority_preference, PriorityPreferenceSpecificsToValue); SET_FIELD(search_engine, SearchEngineSpecificsToValue); SET_FIELD(session, SessionSpecificsToValue); SET_FIELD(synced_notification, SyncedNotificationSpecificsToValue); diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h index a553e56..9003194 100644 --- a/sync/protocol/proto_value_conversions.h +++ b/sync/protocol/proto_value_conversions.h @@ -43,6 +43,7 @@ class NigoriSpecifics; class PasswordSpecifics; class PasswordSpecificsData; class PreferenceSpecifics; +class PriorityPreferenceSpecifics; class SearchEngineSpecifics; class SessionHeader; class SessionSpecifics; @@ -141,6 +142,9 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* DeviceInfoSpecificsToValue( SYNC_EXPORT_PRIVATE base::DictionaryValue* ExperimentsSpecificsToValue( const sync_pb::ExperimentsSpecifics& proto); +SYNC_EXPORT_PRIVATE base::DictionaryValue* PriorityPreferenceSpecificsToValue( + const sync_pb::PriorityPreferenceSpecifics& proto); + SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSettingSpecificsToValue( const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics); diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index bc4e652..2bac903 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -24,6 +24,7 @@ #include "sync/protocol/nigori_specifics.pb.h" #include "sync/protocol/password_specifics.pb.h" #include "sync/protocol/preference_specifics.pb.h" +#include "sync/protocol/priority_preference_specifics.pb.h" #include "sync/protocol/search_engine_specifics.pb.h" #include "sync/protocol/session_specifics.pb.h" #include "sync/protocol/sync.pb.h" @@ -49,7 +50,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(21, MODEL_TYPE_COUNT); + EXPECT_EQ(22, 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 @@ -138,6 +139,10 @@ TEST_F(ProtoValueConversionsTest, BookmarkSpecificsData) { EXPECT_EQ(icon_url, encoded_icon_url); } +TEST_F(ProtoValueConversionsTest, PriorityPreferenceSpecificsToValue) { + TestSpecificsToValue(PriorityPreferenceSpecificsToValue); +} + TEST_F(ProtoValueConversionsTest, DeviceInfoSpecificsToValue) { TestSpecificsToValue(DeviceInfoSpecificsToValue); } @@ -212,6 +217,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { SET_FIELD(password); SET_FIELD(device_info); SET_FIELD(preference); + SET_FIELD(priority_preference); SET_FIELD(search_engine); SET_FIELD(session); SET_FIELD(synced_notification); diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index f8bdd02..6aea1d0 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -31,6 +31,7 @@ import "history_delete_directive_specifics.proto"; import "nigori_specifics.proto"; import "password_specifics.proto"; import "preference_specifics.proto"; +import "priority_preference_specifics.proto"; import "search_engine_specifics.proto"; import "session_specifics.proto"; import "sync_enums.proto"; @@ -105,6 +106,7 @@ message EntitySpecifics { optional SyncedNotificationSpecifics synced_notification = 153108; optional DeviceInfoSpecifics device_info = 154522; optional ExperimentsSpecifics experiments = 161496; + optional PriorityPreferenceSpecifics priority_preference = 163425; } message SyncEntity { diff --git a/sync/protocol/sync_proto.gyp b/sync/protocol/sync_proto.gyp index 8f890f6..4745044 100644 --- a/sync/protocol/sync_proto.gyp +++ b/sync/protocol/sync_proto.gyp @@ -28,6 +28,7 @@ 'nigori_specifics.proto', 'password_specifics.proto', 'preference_specifics.proto', + 'priority_preference_specifics.proto', 'search_engine_specifics.proto', 'session_specifics.proto', 'sync.proto', diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc index a6ee409..1b0bee4 100644 --- a/sync/syncable/model_type.cc +++ b/sync/syncable/model_type.cc @@ -85,6 +85,9 @@ void AddDefaultFieldValue(ModelType datatype, case EXPERIMENTS: specifics->mutable_experiments(); break; + case PRIORITY_PREFERENCES: + specifics->mutable_priority_preference(); + break; default: NOTREACHED() << "No known extension for model type."; } @@ -156,6 +159,9 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) { case EXPERIMENTS: return sync_pb::EntitySpecifics::kExperimentsFieldNumber; break; + case PRIORITY_PREFERENCES: + return sync_pb::EntitySpecifics::kPriorityPreferenceFieldNumber; + break; default: NOTREACHED() << "No known extension for model type."; return 0; @@ -260,6 +266,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { if (specifics.has_experiments()) return EXPERIMENTS; + if (specifics.has_priority_preference()) + return PRIORITY_PREFERENCES; + return UNSPECIFIED; } @@ -290,6 +299,9 @@ ModelTypeSet ControlTypes() { set.Put(ModelTypeFromInt(i)); } + // TODO(albertb): Re-enable this when the server supports it. + set.Remove(PRIORITY_PREFERENCES); + return set; } @@ -344,6 +356,8 @@ const char* ModelTypeToString(ModelType model_type) { return "Device Info"; case EXPERIMENTS: return "Experiments"; + case PRIORITY_PREFERENCES: + return "Priority Preferences"; default: break; } @@ -417,6 +431,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) { return DEVICE_INFO; else if (model_type_string == "Experiments") return EXPERIMENTS; + else if (model_type_string == "Priority Preferences") + return PRIORITY_PREFERENCES; else NOTREACHED() << "No known model type corresponding to " << model_type_string << "."; @@ -493,6 +509,8 @@ std::string ModelTypeToRootTag(ModelType type) { return "google_chrome_device_info"; case EXPERIMENTS: return "google_chrome_experiments"; + case PRIORITY_PREFERENCES: + return "google_chrome_priority_preferences"; default: break; } @@ -523,6 +541,7 @@ const char kHistoryDeleteDirectiveNotificationType[] = const char kSyncedNotificationType[] = "SYNCED_NOTIFICATION"; const char kDeviceInfoNotificationType[] = "DEVICE_INFO"; const char kExperimentsNotificationType[] = "EXPERIMENTS"; +const char kPriorityPreferenceNotificationType[] = "PRIORITY_PREFERENCE"; } // namespace bool RealModelTypeToNotificationType(ModelType model_type, @@ -583,6 +602,8 @@ bool RealModelTypeToNotificationType(ModelType model_type, case EXPERIMENTS: *notification_type = kExperimentsNotificationType; return true; + case PRIORITY_PREFERENCES: + *notification_type = kPriorityPreferenceNotificationType; default: break; } @@ -644,6 +665,9 @@ bool NotificationTypeToRealModelType(const std::string& notification_type, } else if (notification_type == kDeviceInfoNotificationType) { *model_type = DEVICE_INFO;; return true; + } else if (notification_type == kPriorityPreferenceNotificationType) { + *model_type = PRIORITY_PREFERENCES; + return true; } *model_type = UNSPECIFIED; return false; diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h index 790c4fe..7b69cf8 100644 --- a/sync/util/data_type_histogram.h +++ b/sync/util/data_type_histogram.h @@ -93,6 +93,9 @@ case ::syncer::EXPERIMENTS: \ PER_DATA_TYPE_MACRO("Experiments"); \ break; \ + case ::syncer::PRIORITY_PREFERENCES :\ + PER_DATA_TYPE_MACRO("PriorityPreferences"); \ + break; \ default: \ NOTREACHED() << "Unknown datatype " \ << ::syncer::ModelTypeToString(datatype); \ |