diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 00:53:09 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 00:53:09 +0000 |
commit | 2607e0189caf80c28f335eb329646672baa8fa4d (patch) | |
tree | 2be22c61740ea8fd8e552e575b1fb8b7a00235c8 /sync/protocol | |
parent | 0e066ac18a30f4efe873a664d99a2e2f35afdeb5 (diff) | |
download | chromium_src-2607e0189caf80c28f335eb329646672baa8fa4d.zip chromium_src-2607e0189caf80c28f335eb329646672baa8fa4d.tar.gz chromium_src-2607e0189caf80c28f335eb329646672baa8fa4d.tar.bz2 |
Initial support for the 'Experiments' data type
This internal sync type will track flags that enable or disable experimental
features.
This commit includes the protobuf definitions and other infrastructure required
to support the type. It also includes some support for one experimental flag
that will be used to enable or disable encryption. The code to actually
inspect the flag and take action on its value will be included in a later
commit.
The type is not actually enabled in this patch because the server does not yet
support it. Once server support is available, a small follow-up commit will be
required to enable the feature.
BUG=122825
Review URL: https://chromiumcodereview.appspot.com/11144024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162874 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/protocol')
-rw-r--r-- | sync/protocol/experiments_specifics.proto | 24 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.cc | 30 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions.h | 18 | ||||
-rw-r--r-- | sync/protocol/proto_value_conversions_unittest.cc | 16 | ||||
-rw-r--r-- | sync/protocol/sync.proto | 2 | ||||
-rw-r--r-- | sync/protocol/sync_proto.gyp | 1 |
6 files changed, 76 insertions, 15 deletions
diff --git a/sync/protocol/experiments_specifics.proto b/sync/protocol/experiments_specifics.proto new file mode 100644 index 0000000..6d03a7b --- /dev/null +++ b/sync/protocol/experiments_specifics.proto @@ -0,0 +1,24 @@ +// 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 experimental feature flags. + +syntax = "proto2"; + +option optimize_for = LITE_RUNTIME; +option retain_unknown_fields = true; + +package sync_pb; + +// A flag to enable support for keystore encryption. +message KeystoreEncryptionFlags { + optional bool enabled = 1; +} + +// Contains one flag or set of related flags. Each node of the experiments type +// will have a unique_client_tag identifying which flags it contains. By +// convention, the tag name should match the sub-message name. +message ExperimentsSpecifics { + optional KeystoreEncryptionFlags keystore_encryption = 1; +} diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc index 9408346..70b2fcd 100644 --- a/sync/protocol/proto_value_conversions.cc +++ b/sync/protocol/proto_value_conversions.cc @@ -17,6 +17,7 @@ #include "sync/protocol/autofill_specifics.pb.h" #include "sync/protocol/bookmark_specifics.pb.h" #include "sync/protocol/encryption.pb.h" +#include "sync/protocol/experiments_specifics.pb.h" #include "sync/protocol/extension_setting_specifics.pb.h" #include "sync/protocol/extension_specifics.pb.h" #include "sync/protocol/history_delete_directive_specifics.pb.h" @@ -196,14 +197,10 @@ DictionaryValue* PasswordSpecificsDataToValue( return value; } -DictionaryValue* DeviceInfoSpecificsToValue( - const sync_pb::DeviceInfoSpecifics& proto) { +DictionaryValue* KeystoreEncryptionFlagsToValue( + const sync_pb::KeystoreEncryptionFlags& proto) { DictionaryValue* value = new DictionaryValue(); - SET_STR(cache_guid); - SET_STR(client_name); - SET_ENUM(device_type, GetDeviceTypeString); - SET_STR(sync_user_agent); - SET_STR(chrome_version); + SET_BOOL(enabled); return value; } @@ -296,6 +293,24 @@ DictionaryValue* BookmarkSpecificsToValue( return value; } +DictionaryValue* DeviceInfoSpecificsToValue( + const sync_pb::DeviceInfoSpecifics& proto) { + DictionaryValue* value = new DictionaryValue(); + SET_STR(cache_guid); + SET_STR(client_name); + SET_ENUM(device_type, GetDeviceTypeString); + SET_STR(sync_user_agent); + SET_STR(chrome_version); + return value; +} + +DictionaryValue* ExperimentsSpecificsToValue( + const sync_pb::ExperimentsSpecifics& proto) { + DictionaryValue* value = new DictionaryValue(); + SET(keystore_encryption, KeystoreEncryptionFlagsToValue); + return value; +} + DictionaryValue* ExtensionSettingSpecificsToValue( const sync_pb::ExtensionSettingSpecifics& proto) { DictionaryValue* value = new DictionaryValue(); @@ -430,6 +445,7 @@ DictionaryValue* EntitySpecificsToValue( SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); SET_FIELD(bookmark, BookmarkSpecificsToValue); SET_FIELD(device_info, DeviceInfoSpecificsToValue); + SET_FIELD(experiments, ExperimentsSpecificsToValue); SET_FIELD(extension, ExtensionSpecificsToValue); SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h index fac364e..1e3f7a3 100644 --- a/sync/protocol/proto_value_conversions.h +++ b/sync/protocol/proto_value_conversions.h @@ -26,10 +26,14 @@ class DeviceInformation; class EncryptedData; class EntitySpecifics; class EverythingDirective; +class ExperimentsSpecifics; class ExtensionSettingSpecifics; +class ExtensionSettingSpecifics; +class ExtensionSpecifics; class ExtensionSpecifics; class GlobalIdDirective; class HistoryDeleteDirectiveSpecifics; +class KeystoreEncryptionFlagsSpecifics; class NigoriSpecifics; class PasswordSpecifics; class PasswordSpecificsData; @@ -99,6 +103,11 @@ base::DictionaryValue* GlobalIdDirectiveToValue( base::DictionaryValue* TimeRangeDirectiveToValue( const sync_pb::TimeRangeDirective& time_range_directive); +// Sub-protocol of Experiments. + +base::DictionaryValue* KeystoreEncryptionToValue( + const sync_pb::KeystoreEncryptionFlagsSpecifics& proto); + // Main *SpecificsToValue functions. base::DictionaryValue* AppNotificationToValue( @@ -119,6 +128,12 @@ base::DictionaryValue* AutofillProfileSpecificsToValue( base::DictionaryValue* BookmarkSpecificsToValue( const sync_pb::BookmarkSpecifics& bookmark_specifics); +base::DictionaryValue* DeviceInfoSpecificsToValue( + const sync_pb::DeviceInfoSpecifics& device_info_specifics); + +base::DictionaryValue* ExperimentsSpecificsToValue( + const sync_pb::ExperimentsSpecifics& proto); + base::DictionaryValue* ExtensionSettingSpecificsToValue( const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics); @@ -135,9 +150,6 @@ base::DictionaryValue* NigoriSpecificsToValue( base::DictionaryValue* PasswordSpecificsToValue( const sync_pb::PasswordSpecifics& password_specifics); -base::DictionaryValue* DeviceInfoSpecificsToValue( - const sync_pb::DeviceInfoSpecifics& device_info_specifics); - base::DictionaryValue* PreferenceSpecificsToValue( const sync_pb::PreferenceSpecifics& password_specifics); diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc index 3f5d539..e87888c 100644 --- a/sync/protocol/proto_value_conversions_unittest.cc +++ b/sync/protocol/proto_value_conversions_unittest.cc @@ -18,6 +18,7 @@ #include "sync/protocol/bookmark_specifics.pb.h" #include "sync/protocol/device_info_specifics.pb.h" #include "sync/protocol/encryption.pb.h" +#include "sync/protocol/experiments_specifics.pb.h" #include "sync/protocol/extension_setting_specifics.pb.h" #include "sync/protocol/extension_specifics.pb.h" #include "sync/protocol/nigori_specifics.pb.h" @@ -48,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(19, MODEL_TYPE_COUNT); + EXPECT_EQ(20, 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 @@ -132,6 +133,14 @@ TEST_F(ProtoValueConversionsTest, BookmarkSpecificsData) { EXPECT_EQ(base::Int64ToString(creation_time.ToInternalValue()), encoded_time); } +TEST_F(ProtoValueConversionsTest, DeviceInfoSpecificsToValue) { + TestSpecificsToValue(DeviceInfoSpecificsToValue); +} + +TEST_F(ProtoValueConversionsTest, ExperimentsSpecificsToValue) { + TestSpecificsToValue(ExperimentsSpecificsToValue); +} + TEST_F(ProtoValueConversionsTest, ExtensionSettingSpecificsToValue) { TestSpecificsToValue(ExtensionSettingSpecificsToValue); } @@ -152,10 +161,6 @@ TEST_F(ProtoValueConversionsTest, PasswordSpecificsToValue) { TestSpecificsToValue(PasswordSpecificsToValue); } -TEST_F(ProtoValueConversionsTest, DeviceInfoSpecificsToValue) { - TestSpecificsToValue(DeviceInfoSpecificsToValue); -} - TEST_F(ProtoValueConversionsTest, PreferenceSpecificsToValue) { TestSpecificsToValue(PreferenceSpecificsToValue); } @@ -190,6 +195,7 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) { SET_FIELD(autofill); SET_FIELD(autofill_profile); SET_FIELD(bookmark); + SET_FIELD(experiments); SET_FIELD(extension); SET_FIELD(extension_setting); SET_FIELD(history_delete_directive); diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto index b9d1310..2b564e5 100644 --- a/sync/protocol/sync.proto +++ b/sync/protocol/sync.proto @@ -23,6 +23,7 @@ import "client_commands.proto"; import "client_debug_info.proto"; import "device_info_specifics.proto"; import "encryption.proto"; +import "experiments_specifics.proto"; import "extension_setting_specifics.proto"; import "extension_specifics.proto"; import "get_updates_caller_info.proto"; @@ -101,6 +102,7 @@ message EntitySpecifics { optional AppSettingSpecifics app_setting = 103656; optional HistoryDeleteDirectiveSpecifics history_delete_directive = 150251; optional DeviceInfoSpecifics device_info = 154522; + optional ExperimentsSpecifics experiments = 161496; } message SyncEntity { diff --git a/sync/protocol/sync_proto.gyp b/sync/protocol/sync_proto.gyp index d3b9e95..295e329 100644 --- a/sync/protocol/sync_proto.gyp +++ b/sync/protocol/sync_proto.gyp @@ -20,6 +20,7 @@ 'client_debug_info.proto', 'device_info_specifics.proto', 'encryption.proto', + 'experiments_specifics.proto', 'extension_setting_specifics.proto', 'extension_specifics.proto', 'get_updates_caller_info.proto', |