summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/base_node.cc5
-rw-r--r--sync/internal_api/public/base/model_type.h6
-rw-r--r--sync/internal_api/public/base_node.h4
-rw-r--r--sync/internal_api/public/write_node.h4
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc3
-rw-r--r--sync/internal_api/write_node.cc7
-rw-r--r--sync/protocol/experiments_specifics.proto24
-rw-r--r--sync/protocol/proto_value_conversions.cc30
-rw-r--r--sync/protocol/proto_value_conversions.h18
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc16
-rw-r--r--sync/protocol/sync.proto2
-rw-r--r--sync/protocol/sync_proto.gyp1
-rw-r--r--sync/syncable/model_type.cc22
-rw-r--r--sync/util/data_type_histogram.h3
14 files changed, 127 insertions, 18 deletions
diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc
index 8b6b25f..2859cd1 100644
--- a/sync/internal_api/base_node.cc
+++ b/sync/internal_api/base_node.cc
@@ -337,6 +337,11 @@ const sync_pb::DeviceInfoSpecifics& BaseNode::GetDeviceInfoSpecifics() const {
return GetEntitySpecifics().device_info();
}
+const sync_pb::ExperimentsSpecifics& BaseNode::GetExperimentsSpecifics() const {
+ DCHECK_EQ(GetModelType(), EXPERIMENTS);
+ return GetEntitySpecifics().experiments();
+}
+
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 f743bff..0585b7b 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -88,9 +88,11 @@ enum ModelType {
// An object representing a set of Nigori keys.
NIGORI,
FIRST_CONTROL_MODEL_TYPE = NIGORI,
- // Client-specific metadata
+ // Client-specific metadata.
DEVICE_INFO,
- LAST_CONTROL_MODEL_TYPE = DEVICE_INFO,
+ // Flags to enable experimental features.
+ EXPERIMENTS,
+ LAST_CONTROL_MODEL_TYPE = EXPERIMENTS,
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 ff88a48..4b229cd 100644
--- a/sync/internal_api/public/base_node.h
+++ b/sync/internal_api/public/base_node.h
@@ -170,6 +170,10 @@ class BaseNode {
// data. Can only be called if GetModelType() == DEVICE_INFO.
const sync_pb::DeviceInfoSpecifics& GetDeviceInfoSpecifics() const;
+ // Getter specific to the EXPERIMENTS datatype. Returns protobuf
+ // data. Can only be called if GetModelType() == EXPERIMENTS.
+ const sync_pb::ExperimentsSpecifics& GetExperimentsSpecifics() 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 a48f8a1..099b30f 100644
--- a/sync/internal_api/public/write_node.h
+++ b/sync/internal_api/public/write_node.h
@@ -168,6 +168,10 @@ class WriteNode : public BaseNode {
// Should only be called if GetModelType() == DEVICE_INFO.
void SetDeviceInfoSpecifics(const sync_pb::DeviceInfoSpecifics& specifics);
+ // Set the experiments specifics.
+ // Should only be called if GetModelType() == EXPERIMENTS.
+ void SetExperimentsSpecifics(const sync_pb::ExperimentsSpecifics& 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 831d625..2eb5112 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -791,6 +791,7 @@ class SyncManagerTest : public testing::Test,
void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
(*out)[NIGORI] = GROUP_PASSIVE;
(*out)[DEVICE_INFO] = GROUP_PASSIVE;
+ (*out)[EXPERIMENTS] = GROUP_PASSIVE;
(*out)[BOOKMARKS] = GROUP_PASSIVE;
(*out)[THEMES] = GROUP_PASSIVE;
(*out)[SESSIONS] = GROUP_PASSIVE;
@@ -1184,7 +1185,7 @@ TEST_F(SyncManagerTest, GetChildNodeIds) {
const ListValue* nodes = NULL;
ASSERT_TRUE(return_args.Get().GetList(0, &nodes));
ASSERT_TRUE(nodes);
- EXPECT_EQ(7u, nodes->GetSize());
+ EXPECT_EQ(8u, nodes->GetSize());
}
TEST_F(SyncManagerTest, GetChildNodeIdsFailure) {
diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc
index fad906c..5ffa795 100644
--- a/sync/internal_api/write_node.cc
+++ b/sync/internal_api/write_node.cc
@@ -196,6 +196,13 @@ void WriteNode::SetDeviceInfoSpecifics(
SetEntitySpecifics(entity_specifics);
}
+void WriteNode::SetExperimentsSpecifics(
+ const sync_pb::ExperimentsSpecifics& new_value) {
+ sync_pb::EntitySpecifics entity_specifics;
+ entity_specifics.mutable_experiments()->CopyFrom(new_value);
+ SetEntitySpecifics(entity_specifics);
+}
+
void WriteNode::SetEntitySpecifics(
const sync_pb::EntitySpecifics& new_value) {
ModelType new_specifics_type =
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',
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index f4e2361..08094d0 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -79,6 +79,9 @@ void AddDefaultFieldValue(ModelType datatype,
case DEVICE_INFO:
specifics->mutable_device_info();
break;
+ case EXPERIMENTS:
+ specifics->mutable_experiments();
+ break;
default:
NOTREACHED() << "No known extension for model type.";
}
@@ -146,6 +149,9 @@ int GetSpecificsFieldNumberFromModelType(ModelType model_type) {
case DEVICE_INFO:
return sync_pb::EntitySpecifics::kDeviceInfoFieldNumber;
break;
+ case EXPERIMENTS:
+ return sync_pb::EntitySpecifics::kExperimentsFieldNumber;
+ break;
default:
NOTREACHED() << "No known extension for model type.";
return 0;
@@ -244,6 +250,9 @@ ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
if (specifics.has_device_info())
return DEVICE_INFO;
+ if (specifics.has_experiments())
+ return EXPERIMENTS;
+
return UNSPECIFIED;
}
@@ -275,6 +284,9 @@ ModelTypeSet ControlTypes() {
// TODO(rlarocque): Re-enable this when the server supports it.
set.Remove(DEVICE_INFO);
+ // TODO(rlarocque): Re-enable this when the server supports it.
+ set.Remove(EXPERIMENTS);
+
return set;
}
@@ -325,6 +337,8 @@ const char* ModelTypeToString(ModelType model_type) {
return "History Delete Directives";
case DEVICE_INFO:
return "Device Info";
+ case EXPERIMENTS:
+ return "Experiments";
default:
break;
}
@@ -394,6 +408,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return HISTORY_DELETE_DIRECTIVES;
else if (model_type_string == "Device Info")
return DEVICE_INFO;
+ else if (model_type_string == "Experiments")
+ return EXPERIMENTS;
else
NOTREACHED() << "No known model type corresponding to "
<< model_type_string << ".";
@@ -466,6 +482,8 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_history_delete_directives";
case DEVICE_INFO:
return "google_chrome_device_info";
+ case EXPERIMENTS:
+ return "google_chrome_experiments";
default:
break;
}
@@ -494,6 +512,7 @@ const char kAppNotificationNotificationType[] = "APP_NOTIFICATION";
const char kHistoryDeleteDirectiveNotificationType[] =
"HISTORY_DELETE_DIRECTIVE";
const char kDeviceInfoNotificationType[] = "DEVICE_INFO";
+const char kExperimentsNotificationType[] = "EXPERIMENTS";
} // namespace
bool RealModelTypeToNotificationType(ModelType model_type,
@@ -549,6 +568,9 @@ bool RealModelTypeToNotificationType(ModelType model_type,
case DEVICE_INFO:
*notification_type = kDeviceInfoNotificationType;
return true;
+ case EXPERIMENTS:
+ *notification_type = kExperimentsNotificationType;
+ return true;
default:
break;
}
diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h
index faf54bf..d815ab5 100644
--- a/sync/util/data_type_histogram.h
+++ b/sync/util/data_type_histogram.h
@@ -87,6 +87,9 @@
case ::syncer::DEVICE_INFO: \
PER_DATA_TYPE_MACRO("DeviceInfo"); \
break; \
+ case ::syncer::EXPERIMENTS: \
+ PER_DATA_TYPE_MACRO("Experiments"); \
+ break; \
default: \
NOTREACHED() << "Unknown datatype " \
<< ::syncer::ModelTypeToString(datatype); \