summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
Diffstat (limited to 'sync')
-rw-r--r--sync/internal_api/public/base/model_type.h21
-rw-r--r--sync/protocol/proto_value_conversions.cc2
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc5
-rw-r--r--sync/protocol/sync.proto7
-rw-r--r--sync/syncable/model_type.cc20
-rw-r--r--sync/syncable/nigori_util.cc4
-rw-r--r--sync/util/data_type_histogram.h3
7 files changed, 50 insertions, 12 deletions
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index 4b9e721..a44ad19 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -49,6 +49,11 @@ enum ModelType {
// can be represented in the protocol using a specific Message type in the
// EntitySpecifics protocol buffer.
//
+ // WARNING: Modifying the order of these types or inserting a new type above
+ // these will affect numerous histograms that rely on the enum values being
+ // consistent. When adding a new type, add it to the end of the user model
+ // types section, but before the proxy types.
+ //
// A bookmark folder or a bookmark URL object.
BOOKMARKS,
FIRST_USER_MODEL_TYPE = BOOKMARKS, // Declared 2nd, for debugger prettiness.
@@ -90,8 +95,22 @@ enum ModelType {
FAVICON_IMAGES,
// Favicon tracking information.
FAVICON_TRACKING,
- LAST_USER_MODEL_TYPE = FAVICON_TRACKING,
+ // ---- Proxy types ----
+ // Proxy types are excluded from the sync protocol, but are still considered
+ // real user types. By convention, we prefix them with 'PROXY_' to distinguish
+ // them from normal protocol types.
+
+ // Tab sync. This is a placeholder type, so that Sessions can be implicitly
+ // enabled for history sync and tabs sync.
+ PROXY_TABS,
+
+ FIRST_PROXY_TYPE = PROXY_TABS,
+ LAST_PROXY_TYPE = PROXY_TABS,
+
+ LAST_USER_MODEL_TYPE = PROXY_TABS,
+
+ // ---- Control Types ----
// An object representing a set of Nigori keys.
NIGORI,
FIRST_CONTROL_MODEL_TYPE = NIGORI,
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 3964578..bc5b0ae 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -620,6 +620,7 @@ base::DictionaryValue* GetUpdatesMessageToValue(
SET_INT32(batch_size);
SET_REP(from_progress_marker, DataTypeProgressMarkerToValue);
SET_BOOL(streaming);
+ SET_BOOL(need_encryption_key);
SET_BOOL(create_mobile_bookmarks_folder);
return value;
}
@@ -777,6 +778,7 @@ base::DictionaryValue* ClientConfigParamsToValue(
const sync_pb::ClientConfigParams& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
SET_INT32_REP(enabled_type_ids);
+ SET_BOOL(tabs_datatype_enabled);
return value;
}
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index b82045a..6258fa6 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -52,7 +52,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(25, MODEL_TYPE_COUNT);
+ EXPECT_EQ(26, 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
@@ -244,7 +244,8 @@ TEST_F(ProtoValueConversionsTest, EntitySpecificsToValue) {
#undef SET_FIELD
scoped_ptr<DictionaryValue> value(EntitySpecificsToValue(specifics));
- EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE,
+ EXPECT_EQ(MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE -
+ (LAST_PROXY_TYPE - FIRST_PROXY_TYPE + 1),
static_cast<int>(value->size()));
}
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index 934021d..37e4455 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -370,8 +370,13 @@ message ChromiumExtensionsActivity {
// Client specific configuration information.
message ClientConfigParams {
- // The set of data types this client has enabled.
+ // The set of data types this client has enabled. Note that this does not
+ // include proxy types, as they do not have protocol field numbers and are
+ // placeholder types that implicitly enable protocol types.
repeated int32 enabled_type_ids = 1;
+
+ // Whether the PROXY_TABS proxy datatype is enabled on this client.
+ optional bool tabs_datatype_enabled = 2;
};
message CommitMessage {
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index ba7a7f0..99cf1e9 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -329,15 +329,17 @@ ModelTypeSet UserTypes() {
ModelTypeSet UserSelectableTypes() {
ModelTypeSet set;
- set.Put(APPS);
- set.Put(AUTOFILL);
+ // Although the order doesn't technically matter here, it's clearer to keep
+ // these in the same order as their definition in the ModelType enum.
set.Put(BOOKMARKS);
- set.Put(EXTENSIONS);
+ set.Put(PREFERENCES);;
set.Put(PASSWORDS);
- set.Put(PREFERENCES);
- set.Put(SESSIONS);
+ set.Put(AUTOFILL);
set.Put(THEMES);
set.Put(TYPED_URLS);
+ set.Put(EXTENSIONS);
+ set.Put(APPS);
+ set.Put(PROXY_TABS);
return set;
}
@@ -375,7 +377,7 @@ ModelTypeSet ControlTypes() {
ModelTypeSet ProxyTypes() {
ModelTypeSet set;
- // TODO(zea): add a TABS type here.
+ set.Put(PROXY_TABS);
return set;
}
@@ -438,6 +440,8 @@ const char* ModelTypeToString(ModelType model_type) {
return "Favicon Images";
case FAVICON_TRACKING:
return "Favicon Tracking";
+ case PROXY_TABS:
+ return "Tabs";
default:
break;
}
@@ -519,6 +523,8 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return FAVICON_IMAGES;
else if (model_type_string == "Favicon Tracking")
return FAVICON_TRACKING;
+ else if (model_type_string == "Tabs")
+ return PROXY_TABS;
else
NOTREACHED() << "No known model type corresponding to "
<< model_type_string << ".";
@@ -605,6 +611,8 @@ std::string ModelTypeToRootTag(ModelType type) {
return "google_chrome_favicon_images";
case FAVICON_TRACKING:
return "google_chrome_favicon_tracking";
+ case PROXY_TABS:
+ return std::string();
default:
break;
}
diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc
index 0b6c40c..4888f66 100644
--- a/sync/syncable/nigori_util.cc
+++ b/sync/syncable/nigori_util.cc
@@ -252,7 +252,7 @@ void UpdateNigoriFromEncryptedTypes(ModelTypeSet encrypted_types,
bool encrypt_everything,
sync_pb::NigoriSpecifics* nigori) {
nigori->set_encrypt_everything(encrypt_everything);
- COMPILE_ASSERT(25 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
+ COMPILE_ASSERT(26 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
nigori->set_encrypt_bookmarks(
encrypted_types.Has(BOOKMARKS));
nigori->set_encrypt_preferences(
@@ -286,7 +286,7 @@ ModelTypeSet GetEncryptedTypesFromNigori(
return ModelTypeSet::All();
ModelTypeSet encrypted_types;
- COMPILE_ASSERT(25 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
+ COMPILE_ASSERT(26 == MODEL_TYPE_COUNT, UpdateEncryptedTypes);
if (nigori.encrypt_bookmarks())
encrypted_types.Put(BOOKMARKS);
if (nigori.encrypt_preferences())
diff --git a/sync/util/data_type_histogram.h b/sync/util/data_type_histogram.h
index d3dfd73..c911ce4 100644
--- a/sync/util/data_type_histogram.h
+++ b/sync/util/data_type_histogram.h
@@ -105,6 +105,9 @@
case ::syncer::FAVICON_TRACKING: \
PER_DATA_TYPE_MACRO("FaviconTracking"); \
break; \
+ case ::syncer::PROXY_TABS :\
+ PER_DATA_TYPE_MACRO("Tabs"); \
+ break; \
default: \
NOTREACHED() << "Unknown datatype " \
<< ::syncer::ModelTypeToString(datatype); \