summaryrefslogtreecommitdiffstats
path: root/sync/protocol
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2015-05-07 14:16:45 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-07 21:17:10 +0000
commitc6bb7fcb643e4ca240f793e1455155ea2699ce5b (patch)
treef3b8bc8bb8b617f3cf4be22be81bb8b7b9f93aa0 /sync/protocol
parent61cae85448cfeb793270e804b5ad1023993279c5 (diff)
downloadchromium_src-c6bb7fcb643e4ca240f793e1455155ea2699ce5b.zip
chromium_src-c6bb7fcb643e4ca240f793e1455155ea2699ce5b.tar.gz
chromium_src-c6bb7fcb643e4ca240f793e1455155ea2699ce5b.tar.bz2
Convert some parts of sync/ to use of scoped_ptr instead of bare ptrs
for base::Value handling. BUG=none Review URL: https://codereview.chromium.org/1126913002 Cr-Commit-Position: refs/heads/master@{#328830}
Diffstat (limited to 'sync/protocol')
-rw-r--r--sync/protocol/proto_value_conversions.cc361
-rw-r--r--sync/protocol/proto_value_conversions.h159
-rw-r--r--sync/protocol/proto_value_conversions_unittest.cc4
3 files changed, 270 insertions, 254 deletions
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index f169f4f..1e74474 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -49,33 +49,28 @@ namespace {
// Basic Type -> Value functions.
-base::StringValue* MakeInt64Value(int64 x) {
- return new base::StringValue(base::Int64ToString(x));
+scoped_ptr<base::StringValue> MakeInt64Value(int64 x) {
+ return make_scoped_ptr(new base::StringValue(base::Int64ToString(x)));
}
// TODO(akalin): Perhaps make JSONWriter support BinaryValue and use
// that instead of a StringValue.
-base::StringValue* MakeBytesValue(const std::string& bytes) {
+std::string Base64EncodeString(const std::string& bytes) {
std::string bytes_base64;
base::Base64Encode(bytes, &bytes_base64);
- return new base::StringValue(bytes_base64);
+ return bytes_base64;
}
-base::StringValue* MakeStringValue(const std::string& str) {
- return new base::StringValue(str);
-}
-
-// T is the enum type.
-template <class T>
-base::StringValue* MakeEnumValue(T t, const char* (*converter_fn)(T)) {
- return new base::StringValue(converter_fn(t));
+scoped_ptr<base::StringValue> MakeStringValue(const std::string& str) {
+ return make_scoped_ptr(new base::StringValue(str));
}
// T is the field type, F is either RepeatedField or RepeatedPtrField,
// and V is a subclass of Value.
template <class T, class F, class V>
-base::ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) {
- base::ListValue* list = new base::ListValue();
+scoped_ptr<base::ListValue> MakeRepeatedValue(const F& fields,
+ V (*converter_fn)(T)) {
+ scoped_ptr<base::ListValue> list(new base::ListValue());
for (typename F::const_iterator it = fields.begin(); it != fields.end();
++it) {
list->Append(converter_fn(*it));
@@ -83,39 +78,38 @@ base::ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) {
return list;
}
-base::StringValue* MakeTimestampValue(int64 tm) {
- return new base::StringValue(
- base::TimeFormatShortDateAndTime(syncer::ProtoTimeToTime(tm)));
+base::string16 TimestampToString(int64 tm) {
+ return base::TimeFormatShortDateAndTime(syncer::ProtoTimeToTime(tm));
}
} // namespace
// Helper macros to reduce the amount of boilerplate.
-#define SET(field, fn) \
- if (proto.has_##field()) { \
- value->Set(#field, fn(proto.field())); \
+#define SET_TYPE(field, set_fn, transform) \
+ if (proto.has_##field()) { \
+ value->set_fn(#field, transform(proto.field())); \
}
+#define SET(field, fn) SET_TYPE(field, Set, fn)
#define SET_REP(field, fn) \
value->Set(#field, MakeRepeatedValue(proto.field(), fn))
-#define SET_ENUM(field, fn) \
- value->Set(#field, MakeEnumValue(proto.field(), fn))
+#define SET_ENUM(field, fn) SET_TYPE(field, SetString, fn)
-#define SET_BOOL(field) SET(field, new base::FundamentalValue)
-#define SET_BYTES(field) SET(field, MakeBytesValue)
-#define SET_INT32(field) SET(field, MakeInt64Value)
+#define SET_BOOL(field) SET_TYPE(field, SetBoolean, )
+#define SET_BYTES(field) SET_TYPE(field, SetString, Base64EncodeString)
+#define SET_INT32(field) SET_TYPE(field, SetString, base::Int64ToString)
#define SET_INT32_REP(field) SET_REP(field, MakeInt64Value)
-#define SET_INT64(field) SET(field, MakeInt64Value)
+#define SET_INT64(field) SET_TYPE(field, SetString, base::Int64ToString)
#define SET_INT64_REP(field) SET_REP(field, MakeInt64Value)
-#define SET_STR(field) SET(field, new base::StringValue)
-#define SET_TIME_STR(field) SET(field, MakeTimestampValue)
-#define SET_STR_REP(field) \
- value->Set(#field, \
- MakeRepeatedValue<const std::string&, \
- google::protobuf::RepeatedPtrField< \
- std::string >, \
- base::StringValue>(proto.field(), \
- MakeStringValue))
+#define SET_STR(field) SET_TYPE(field, SetString, )
+#define SET_TIME_STR(field) SET_TYPE(field, SetString, TimestampToString)
+#define SET_STR_REP(field) \
+ value->Set( \
+ #field, \
+ MakeRepeatedValue<const std::string&, \
+ google::protobuf::RepeatedPtrField<std::string>, \
+ scoped_ptr<base::StringValue>>(proto.field(), \
+ MakeStringValue))
#define SET_EXPERIMENT_ENABLED_FIELD(field) \
do { \
if (proto.has_##field() && \
@@ -136,35 +130,36 @@ base::StringValue* MakeTimestampValue(int64 tm) {
// If you add another macro, don't forget to add an #undef at the end
// of this file, too.
-base::DictionaryValue* EncryptedDataToValue(
+scoped_ptr<base::DictionaryValue> EncryptedDataToValue(
const sync_pb::EncryptedData& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(key_name);
// TODO(akalin): Shouldn't blob be of type bytes instead of string?
SET_BYTES(blob);
return value;
}
-base::DictionaryValue* AppSettingsToValue(
+scoped_ptr<base::DictionaryValue> AppSettingsToValue(
const sync_pb::AppNotificationSettings& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BOOL(initial_setup_done);
SET_BOOL(disabled);
SET_STR(oauth_client_id);
return value;
}
-base::DictionaryValue* SessionHeaderToValue(
+scoped_ptr<base::DictionaryValue> SessionHeaderToValue(
const sync_pb::SessionHeader& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_REP(window, SessionWindowToValue);
SET_STR(client_name);
SET_ENUM(device_type, GetDeviceTypeString);
return value;
}
-base::DictionaryValue* SessionTabToValue(const sync_pb::SessionTab& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+scoped_ptr<base::DictionaryValue> SessionTabToValue(
+ const sync_pb::SessionTab& proto) {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(tab_id);
SET_INT32(window_id);
SET_INT32(tab_visual_index);
@@ -179,9 +174,9 @@ base::DictionaryValue* SessionTabToValue(const sync_pb::SessionTab& proto) {
return value;
}
-base::DictionaryValue* SessionWindowToValue(
+scoped_ptr<base::DictionaryValue> SessionWindowToValue(
const sync_pb::SessionWindow& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(window_id);
SET_INT32(selected_tab_index);
SET_INT32_REP(tab);
@@ -189,9 +184,9 @@ base::DictionaryValue* SessionWindowToValue(
return value;
}
-base::DictionaryValue* TabNavigationToValue(
+scoped_ptr<base::DictionaryValue> TabNavigationToValue(
const sync_pb::TabNavigation& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(virtual_url);
SET_STR(referrer);
SET_STR(title);
@@ -219,16 +214,16 @@ base::DictionaryValue* TabNavigationToValue(
return value;
}
-base::DictionaryValue* NavigationRedirectToValue(
+scoped_ptr<base::DictionaryValue> NavigationRedirectToValue(
const sync_pb::NavigationRedirect& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(url);
return value;
}
-base::DictionaryValue* PasswordSpecificsDataToValue(
+scoped_ptr<base::DictionaryValue> PasswordSpecificsDataToValue(
const sync_pb::PasswordSpecificsData& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(scheme);
SET_STR(signon_realm);
SET_STR(origin);
@@ -249,26 +244,26 @@ base::DictionaryValue* PasswordSpecificsDataToValue(
return value;
}
-base::DictionaryValue* GlobalIdDirectiveToValue(
+scoped_ptr<base::DictionaryValue> GlobalIdDirectiveToValue(
const sync_pb::GlobalIdDirective& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT64_REP(global_id);
SET_INT64(start_time_usec);
SET_INT64(end_time_usec);
return value;
}
-base::DictionaryValue* TimeRangeDirectiveToValue(
+scoped_ptr<base::DictionaryValue> TimeRangeDirectiveToValue(
const sync_pb::TimeRangeDirective& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT64(start_time_usec);
SET_INT64(end_time_usec);
return value;
}
-base::DictionaryValue* AppListSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AppListSpecificsToValue(
const sync_pb::AppListSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(item_id);
SET_ENUM(item_type, GetAppListItemTypeString);
SET_STR(item_name);
@@ -278,9 +273,9 @@ base::DictionaryValue* AppListSpecificsToValue(
return value;
}
-base::DictionaryValue* AppNotificationToValue(
+scoped_ptr<base::DictionaryValue> AppNotificationToValue(
const sync_pb::AppNotification& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(guid);
SET_STR(app_id);
SET_INT64(creation_timestamp_ms);
@@ -291,24 +286,24 @@ base::DictionaryValue* AppNotificationToValue(
return value;
}
-base::DictionaryValue* AppSettingSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AppSettingSpecificsToValue(
const sync_pb::AppSettingSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(extension_setting, ExtensionSettingSpecificsToValue);
return value;
}
-base::DictionaryValue* LinkedAppIconInfoToValue(
+scoped_ptr<base::DictionaryValue> LinkedAppIconInfoToValue(
const sync_pb::LinkedAppIconInfo& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(url);
SET_INT32(size);
return value;
}
-base::DictionaryValue* AppSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AppSpecificsToValue(
const sync_pb::AppSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(extension, ExtensionSpecificsToValue);
SET(notification_settings, AppSettingsToValue);
SET_STR(app_launch_ordinal);
@@ -322,9 +317,9 @@ base::DictionaryValue* AppSpecificsToValue(
return value;
}
-base::DictionaryValue* AutofillSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AutofillSpecificsToValue(
const sync_pb::AutofillSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(name);
SET_STR(value);
SET_INT64_REP(usage_timestamp);
@@ -332,9 +327,9 @@ base::DictionaryValue* AutofillSpecificsToValue(
return value;
}
-base::DictionaryValue* AutofillProfileSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue(
const sync_pb::AutofillProfileSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(guid);
SET_STR(origin);
SET_INT64(use_count);
@@ -363,9 +358,9 @@ base::DictionaryValue* AutofillProfileSpecificsToValue(
return value;
}
-base::DictionaryValue* AutofillWalletSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue(
const sync_pb::AutofillWalletSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_ENUM(type, GetWalletInfoTypeString);
if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) {
@@ -378,17 +373,17 @@ base::DictionaryValue* AutofillWalletSpecificsToValue(
return value;
}
-base::DictionaryValue* MetaInfoToValue(
+scoped_ptr<base::DictionaryValue> MetaInfoToValue(
const sync_pb::MetaInfo& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(key);
SET_STR(value);
return value;
}
-base::DictionaryValue* BookmarkSpecificsToValue(
+scoped_ptr<base::DictionaryValue> BookmarkSpecificsToValue(
const sync_pb::BookmarkSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(url);
SET_BYTES(favicon);
SET_STR(title);
@@ -398,9 +393,9 @@ base::DictionaryValue* BookmarkSpecificsToValue(
return value;
}
-base::DictionaryValue* DeviceInfoSpecificsToValue(
+scoped_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue(
const sync_pb::DeviceInfoSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(cache_guid);
SET_STR(client_name);
SET_ENUM(device_type, GetDeviceTypeString);
@@ -411,18 +406,18 @@ base::DictionaryValue* DeviceInfoSpecificsToValue(
return value;
}
-base::DictionaryValue* DictionarySpecificsToValue(
+scoped_ptr<base::DictionaryValue> DictionarySpecificsToValue(
const sync_pb::DictionarySpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(word);
return value;
}
namespace {
-base::DictionaryValue* FaviconSyncFlagsToValue(
+scoped_ptr<base::DictionaryValue> FaviconSyncFlagsToValue(
const sync_pb::FaviconSyncFlags& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BOOL(enabled);
SET_INT32(favicon_sync_limit);
return value;
@@ -430,9 +425,9 @@ base::DictionaryValue* FaviconSyncFlagsToValue(
} // namespace
-base::DictionaryValue* ExperimentsSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ExperimentsSpecificsToValue(
const sync_pb::ExperimentsSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption);
SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives);
SET_EXPERIMENT_ENABLED_FIELD(autofill_culling);
@@ -444,18 +439,18 @@ base::DictionaryValue* ExperimentsSpecificsToValue(
return value;
}
-base::DictionaryValue* ExtensionSettingSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue(
const sync_pb::ExtensionSettingSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(extension_id);
SET_STR(key);
SET_STR(value);
return value;
}
-base::DictionaryValue* ExtensionSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ExtensionSpecificsToValue(
const sync_pb::ExtensionSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(id);
SET_STR(version);
SET_STR(update_url);
@@ -469,9 +464,9 @@ base::DictionaryValue* ExtensionSpecificsToValue(
}
namespace {
-base::DictionaryValue* FaviconDataToValue(
+scoped_ptr<base::DictionaryValue> FaviconDataToValue(
const sync_pb::FaviconData& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BYTES(favicon);
SET_INT32(width);
SET_INT32(height);
@@ -479,9 +474,9 @@ base::DictionaryValue* FaviconDataToValue(
}
} // namespace
-base::DictionaryValue* FaviconImageSpecificsToValue(
+scoped_ptr<base::DictionaryValue> FaviconImageSpecificsToValue(
const sync_pb::FaviconImageSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(favicon_url);
SET(favicon_web, FaviconDataToValue);
SET(favicon_web_32, FaviconDataToValue);
@@ -490,34 +485,34 @@ base::DictionaryValue* FaviconImageSpecificsToValue(
return value;
}
-base::DictionaryValue* FaviconTrackingSpecificsToValue(
+scoped_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue(
const sync_pb::FaviconTrackingSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(favicon_url);
SET_INT64(last_visit_time_ms)
SET_BOOL(is_bookmarked);
return value;
}
-base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue(
+scoped_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue(
const sync_pb::HistoryDeleteDirectiveSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(global_id_directive, GlobalIdDirectiveToValue);
SET(time_range_directive, TimeRangeDirectiveToValue);
return value;
}
-base::DictionaryValue* ManagedUserSettingSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue(
const sync_pb::ManagedUserSettingSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(name);
SET_STR(value);
return value;
}
-base::DictionaryValue* ManagedUserSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ManagedUserSpecificsToValue(
const sync_pb::ManagedUserSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(id);
SET_STR(name);
SET_BOOL(acknowledged);
@@ -527,9 +522,9 @@ base::DictionaryValue* ManagedUserSpecificsToValue(
return value;
}
-base::DictionaryValue* ManagedUserSharedSettingSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue(
const sync_pb::ManagedUserSharedSettingSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(mu_id);
SET_STR(key);
SET_STR(value);
@@ -537,17 +532,17 @@ base::DictionaryValue* ManagedUserSharedSettingSpecificsToValue(
return value;
}
-base::DictionaryValue* ManagedUserWhitelistSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue(
const sync_pb::ManagedUserWhitelistSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(id);
SET_STR(name);
return value;
}
-base::DictionaryValue* NigoriSpecificsToValue(
+scoped_ptr<base::DictionaryValue> NigoriSpecificsToValue(
const sync_pb::NigoriSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(encryption_keybag, EncryptedDataToValue);
SET_BOOL(keybag_is_frozen);
SET_BOOL(encrypt_bookmarks);
@@ -574,59 +569,57 @@ base::DictionaryValue* NigoriSpecificsToValue(
return value;
}
-base::DictionaryValue* ArticlePageToValue(
+scoped_ptr<base::DictionaryValue> ArticlePageToValue(
const sync_pb::ArticlePage& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(url);
return value;
}
-base::DictionaryValue* ArticleSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ArticleSpecificsToValue(
const sync_pb::ArticleSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(entry_id);
SET_STR(title);
SET_REP(pages, ArticlePageToValue);
return value;
}
-base::DictionaryValue* PasswordSpecificsToValue(
+scoped_ptr<base::DictionaryValue> PasswordSpecificsToValue(
const sync_pb::PasswordSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(encrypted, EncryptedDataToValue);
return value;
}
-base::DictionaryValue* PreferenceSpecificsToValue(
+scoped_ptr<base::DictionaryValue> PreferenceSpecificsToValue(
const sync_pb::PreferenceSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(name);
SET_STR(value);
return value;
}
-base::DictionaryValue* PriorityPreferenceSpecificsToValue(
+scoped_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue(
const sync_pb::PriorityPreferenceSpecifics& specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_FIELD(preference, PreferenceSpecificsToValue);
return value;
}
-base::DictionaryValue* SyncedNotificationAppInfoSpecificsToValue(
+scoped_ptr<base::DictionaryValue> SyncedNotificationAppInfoSpecificsToValue(
const sync_pb::SyncedNotificationAppInfoSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
- return value;
+ return make_scoped_ptr(new base::DictionaryValue());
}
-base::DictionaryValue* SyncedNotificationSpecificsToValue(
+scoped_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue(
const sync_pb::SyncedNotificationSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
- return value;
+ return make_scoped_ptr(new base::DictionaryValue());
}
-base::DictionaryValue* SearchEngineSpecificsToValue(
+scoped_ptr<base::DictionaryValue> SearchEngineSpecificsToValue(
const sync_pb::SearchEngineSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(short_name);
SET_STR(keyword);
SET_STR(favicon_url);
@@ -653,9 +646,9 @@ base::DictionaryValue* SearchEngineSpecificsToValue(
return value;
}
-base::DictionaryValue* SessionSpecificsToValue(
+scoped_ptr<base::DictionaryValue> SessionSpecificsToValue(
const sync_pb::SessionSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(session_tag);
SET(header, SessionHeaderToValue);
SET(tab, SessionTabToValue);
@@ -663,9 +656,9 @@ base::DictionaryValue* SessionSpecificsToValue(
return value;
}
-base::DictionaryValue* ThemeSpecificsToValue(
+scoped_ptr<base::DictionaryValue> ThemeSpecificsToValue(
const sync_pb::ThemeSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BOOL(use_custom_theme);
SET_BOOL(use_system_theme_by_default);
SET_STR(custom_theme_name);
@@ -674,9 +667,9 @@ base::DictionaryValue* ThemeSpecificsToValue(
return value;
}
-base::DictionaryValue* TypedUrlSpecificsToValue(
+scoped_ptr<base::DictionaryValue> TypedUrlSpecificsToValue(
const sync_pb::TypedUrlSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(url);
SET_STR(title);
SET_BOOL(hidden);
@@ -685,9 +678,9 @@ base::DictionaryValue* TypedUrlSpecificsToValue(
return value;
}
-base::DictionaryValue* WalletMaskedCreditCardToValue(
+scoped_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue(
const sync_pb::WalletMaskedCreditCard& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(id);
SET_ENUM(status, GetWalletCardStatusString);
SET_STR(name_on_card);
@@ -698,9 +691,9 @@ base::DictionaryValue* WalletMaskedCreditCardToValue(
return value;
}
-base::DictionaryValue* WalletPostalAddressToValue(
+scoped_ptr<base::DictionaryValue> WalletPostalAddressToValue(
const sync_pb::WalletPostalAddress& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(recipient_name);
SET_STR(company_name);
SET_STR_REP(street_address);
@@ -716,18 +709,18 @@ base::DictionaryValue* WalletPostalAddressToValue(
return value;
}
-base::DictionaryValue* WifiCredentialSpecificsToValue(
+scoped_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue(
const sync_pb::WifiCredentialSpecifics& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BYTES(ssid);
SET_ENUM(security_class, GetWifiCredentialSecurityClassString);
SET_BYTES(passphrase);
return value;
}
-base::DictionaryValue* EntitySpecificsToValue(
+scoped_ptr<base::DictionaryValue> EntitySpecificsToValue(
const sync_pb::EntitySpecifics& specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_FIELD(app, AppSpecificsToValue);
SET_FIELD(app_list, AppListSpecificsToValue);
SET_FIELD(app_notification, AppNotificationToValue);
@@ -775,9 +768,10 @@ base::StringValue* UniquePositionToStringValue(
} // namespace
-base::DictionaryValue* SyncEntityToValue(const sync_pb::SyncEntity& proto,
- bool include_specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+scoped_ptr<base::DictionaryValue> SyncEntityToValue(
+ const sync_pb::SyncEntity& proto,
+ bool include_specifics) {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(id_string);
SET_STR(parent_id_string);
SET_STR(old_parent_id);
@@ -816,18 +810,18 @@ base::ListValue* SyncEntitiesToValue(
return list;
}
-base::DictionaryValue* ChromiumExtensionActivityToValue(
+scoped_ptr<base::DictionaryValue> ChromiumExtensionActivityToValue(
const sync_pb::ChromiumExtensionsActivity& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(extension_id);
SET_INT32(bookmark_writes_since_last_commit);
return value;
}
-base::DictionaryValue* CommitMessageToValue(
+scoped_ptr<base::DictionaryValue> CommitMessageToValue(
const sync_pb::CommitMessage& proto,
bool include_specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->Set("entries",
SyncEntitiesToValue(proto.entries(), include_specifics));
SET_STR(cache_guid);
@@ -836,9 +830,9 @@ base::DictionaryValue* CommitMessageToValue(
return value;
}
-base::DictionaryValue* GetUpdateTriggersToValue(
+scoped_ptr<base::DictionaryValue> GetUpdateTriggersToValue(
const sync_pb::GetUpdateTriggers& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR_REP(notification_hint);
SET_BOOL(client_dropped_hints);
SET_BOOL(invalidations_out_of_sync);
@@ -847,9 +841,9 @@ base::DictionaryValue* GetUpdateTriggersToValue(
return value;
}
-base::DictionaryValue* DataTypeProgressMarkerToValue(
+scoped_ptr<base::DictionaryValue> DataTypeProgressMarkerToValue(
const sync_pb::DataTypeProgressMarker& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(data_type_id);
SET_BYTES(token);
SET_INT64(timestamp_token_for_migration);
@@ -858,26 +852,26 @@ base::DictionaryValue* DataTypeProgressMarkerToValue(
return value;
}
-base::DictionaryValue* DataTypeContextToValue(
+scoped_ptr<base::DictionaryValue> DataTypeContextToValue(
const sync_pb::DataTypeContext& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(data_type_id);
SET_STR(context);
SET_INT64(version);
return value;
}
-base::DictionaryValue* GetUpdatesCallerInfoToValue(
+scoped_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue(
const sync_pb::GetUpdatesCallerInfo& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_ENUM(source, GetUpdatesSourceString);
SET_BOOL(notifications_enabled);
return value;
}
-base::DictionaryValue* GetUpdatesMessageToValue(
+scoped_ptr<base::DictionaryValue> GetUpdatesMessageToValue(
const sync_pb::GetUpdatesMessage& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(caller_info, GetUpdatesCallerInfoToValue);
SET_BOOL(fetch_folders);
SET_INT32(batch_size);
@@ -890,15 +884,16 @@ base::DictionaryValue* GetUpdatesMessageToValue(
return value;
}
-base::DictionaryValue* ClientStatusToValue(const sync_pb::ClientStatus& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+scoped_ptr<base::DictionaryValue> ClientStatusToValue(
+ const sync_pb::ClientStatus& proto) {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_BOOL(hierarchy_conflict_detected);
return value;
}
-base::DictionaryValue* EntryResponseToValue(
+scoped_ptr<base::DictionaryValue> EntryResponseToValue(
const sync_pb::CommitResponse::EntryResponse& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_ENUM(response_type, GetResponseTypeString);
SET_STR(id_string);
SET_STR(parent_id_string);
@@ -910,17 +905,17 @@ base::DictionaryValue* EntryResponseToValue(
return value;
}
-base::DictionaryValue* CommitResponseToValue(
+scoped_ptr<base::DictionaryValue> CommitResponseToValue(
const sync_pb::CommitResponse& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_REP(entryresponse, EntryResponseToValue);
return value;
}
-base::DictionaryValue* GetUpdatesResponseToValue(
+scoped_ptr<base::DictionaryValue> GetUpdatesResponseToValue(
const sync_pb::GetUpdatesResponse& proto,
bool include_specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->Set("entries",
SyncEntitiesToValue(proto.entries(), include_specifics));
SET_INT64(changes_remaining);
@@ -929,9 +924,9 @@ base::DictionaryValue* GetUpdatesResponseToValue(
return value;
}
-base::DictionaryValue* ClientCommandToValue(
+scoped_ptr<base::DictionaryValue> ClientCommandToValue(
const sync_pb::ClientCommand& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(set_sync_poll_interval);
SET_INT32(set_sync_long_poll_interval);
SET_INT32(max_commit_batch_size);
@@ -941,9 +936,9 @@ base::DictionaryValue* ClientCommandToValue(
return value;
}
-base::DictionaryValue* ErrorToValue(
+scoped_ptr<base::DictionaryValue> ErrorToValue(
const sync_pb::ClientToServerResponse::Error& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_ENUM(error_type, GetErrorTypeString);
SET_STR(error_description);
SET_STR(url);
@@ -953,10 +948,10 @@ base::DictionaryValue* ErrorToValue(
} // namespace
-base::DictionaryValue* ClientToServerResponseToValue(
+scoped_ptr<base::DictionaryValue> ClientToServerResponseToValue(
const sync_pb::ClientToServerResponse& proto,
bool include_specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET(commit, CommitResponseToValue);
if (proto.has_get_updates()) {
value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(),
@@ -972,10 +967,10 @@ base::DictionaryValue* ClientToServerResponseToValue(
return value;
}
-base::DictionaryValue* ClientToServerMessageToValue(
+scoped_ptr<base::DictionaryValue> ClientToServerMessageToValue(
const sync_pb::ClientToServerMessage& proto,
bool include_specifics) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(share);
SET_INT32(protocol_version);
if (proto.has_commit()) {
@@ -991,9 +986,9 @@ base::DictionaryValue* ClientToServerMessageToValue(
return value;
}
-base::DictionaryValue* DatatypeAssociationStatsToValue(
+scoped_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue(
const sync_pb::DatatypeAssociationStats& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(data_type_id);
SET_INT32(num_local_items_before_association);
SET_INT32(num_sync_items_before_association);
@@ -1015,9 +1010,9 @@ base::DictionaryValue* DatatypeAssociationStatsToValue(
return value;
}
-base::DictionaryValue* DebugEventInfoToValue(
+scoped_ptr<base::DictionaryValue> DebugEventInfoToValue(
const sync_pb::DebugEventInfo& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_ENUM(singleton_event, SingletonDebugEventTypeString);
SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue);
SET_INT32(nudging_datatype);
@@ -1026,8 +1021,9 @@ base::DictionaryValue* DebugEventInfoToValue(
return value;
}
-base::DictionaryValue* DebugInfoToValue(const sync_pb::DebugInfo& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+scoped_ptr<base::DictionaryValue> DebugInfoToValue(
+ const sync_pb::DebugInfo& proto) {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_REP(events, DebugEventInfoToValue);
SET_BOOL(cryptographer_ready);
SET_BOOL(cryptographer_has_pending_keys);
@@ -1035,9 +1031,9 @@ base::DictionaryValue* DebugInfoToValue(const sync_pb::DebugInfo& proto) {
return value;
}
-base::DictionaryValue* SyncCycleCompletedEventInfoToValue(
+scoped_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue(
const sync_pb::SyncCycleCompletedEventInfo& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32(num_encryption_conflicts);
SET_INT32(num_hierarchy_conflicts);
SET_INT32(num_server_conflicts);
@@ -1047,21 +1043,22 @@ base::DictionaryValue* SyncCycleCompletedEventInfoToValue(
return value;
}
-base::DictionaryValue* ClientConfigParamsToValue(
+scoped_ptr<base::DictionaryValue> ClientConfigParamsToValue(
const sync_pb::ClientConfigParams& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_INT32_REP(enabled_type_ids);
SET_BOOL(tabs_datatype_enabled);
return value;
}
-base::DictionaryValue* AttachmentIdProtoToValue(
+scoped_ptr<base::DictionaryValue> AttachmentIdProtoToValue(
const sync_pb::AttachmentIdProto& proto) {
- base::DictionaryValue* value = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
SET_STR(unique_id);
return value;
}
+#undef SET_TYPE
#undef SET
#undef SET_REP
diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h
index 8aa02ad..7d466b2 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -7,6 +7,7 @@
#ifndef SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_
#define SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_
+#include "base/memory/scoped_ptr.h"
#include "sync/base/sync_export.h"
namespace base {
@@ -93,204 +94,222 @@ namespace syncer {
// caller.
// TODO(akalin): Perhaps extend this to decrypt?
-SYNC_EXPORT_PRIVATE base::DictionaryValue* EncryptedDataToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> EncryptedDataToValue(
const sync_pb::EncryptedData& encrypted_data);
// Sub-protocol of AppListSpecifics.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AppListSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppListSpecificsToValue(
const sync_pb::AppListSpecifics& proto);
// Sub-protocols of AppSpecifics.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSettingsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppSettingsToValue(
const sync_pb::AppNotificationSettings& app_notification_settings);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* LinkedAppIconInfoToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> LinkedAppIconInfoToValue(
const sync_pb::LinkedAppIconInfo& linked_app_icon_info);
// Sub-protocols of SessionSpecifics.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionHeaderToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionHeaderToValue(
const sync_pb::SessionHeader& session_header);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionTabToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionTabToValue(
const sync_pb::SessionTab& session_tab);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionWindowToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionWindowToValue(
const sync_pb::SessionWindow& session_window);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* TabNavigationToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> TabNavigationToValue(
const sync_pb::TabNavigation& tab_navigation);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* NavigationRedirectToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> NavigationRedirectToValue(
const sync_pb::NavigationRedirect& navigation_redirect);
// Sub-protocol of PasswordSpecifics.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsDataToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+PasswordSpecificsDataToValue(
const sync_pb::PasswordSpecificsData& password_specifics_data);
// Sub-protocol of NigoriSpecifics.
-base::DictionaryValue* DeviceInformationToValue(
+scoped_ptr<base::DictionaryValue> DeviceInformationToValue(
const sync_pb::DeviceInformation& device_information);
// Sub-protocol of HistoryDeleteDirectiveSpecifics.
-base::DictionaryValue* GlobalIdDirectiveToValue(
+scoped_ptr<base::DictionaryValue> GlobalIdDirectiveToValue(
const sync_pb::GlobalIdDirective& global_id_directive);
-base::DictionaryValue* TimeRangeDirectiveToValue(
+scoped_ptr<base::DictionaryValue> TimeRangeDirectiveToValue(
const sync_pb::TimeRangeDirective& time_range_directive);
// Sub-protocol of Experiments.
-base::DictionaryValue* KeystoreEncryptionToValue(
+scoped_ptr<base::DictionaryValue> KeystoreEncryptionToValue(
const sync_pb::KeystoreEncryptionFlagsSpecifics& proto);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionSpecificsToValue(
const sync_pb::SessionSpecifics& session_specifics);
// Main *SpecificsToValue functions.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AppNotificationToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppNotificationToValue(
const sync_pb::AppNotification& app_notification_specifics);
-base::DictionaryValue* AppSettingSpecificsToValue(
+scoped_ptr<base::DictionaryValue> AppSettingSpecificsToValue(
const sync_pb::AppSettingSpecifics& app_setting_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppSpecificsToValue(
const sync_pb::AppSpecifics& app_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ArticleSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ArticleSpecificsToValue(
const sync_pb::ArticleSpecifics& article_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AutofillSpecificsToValue(
const sync_pb::AutofillSpecifics& autofill_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillProfileSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+AutofillProfileSpecificsToValue(
const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillWalletSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+AutofillWalletSpecificsToValue(
const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* BookmarkSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> BookmarkSpecificsToValue(
const sync_pb::BookmarkSpecifics& bookmark_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* DeviceInfoSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+DeviceInfoSpecificsToValue(
const sync_pb::DeviceInfoSpecifics& device_info_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* DictionarySpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+DictionarySpecificsToValue(
const sync_pb::DictionarySpecifics& dictionary_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ExperimentsSpecificsToValue(
- const sync_pb::ExperimentsSpecifics& proto);
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ExperimentsSpecificsToValue(const sync_pb::ExperimentsSpecifics& proto);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* PriorityPreferenceSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+PriorityPreferenceSpecificsToValue(
const sync_pb::PriorityPreferenceSpecifics& proto);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSettingSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ExtensionSettingSpecificsToValue(
const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ExtensionSpecificsToValue(
const sync_pb::ExtensionSpecifics& extension_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* FaviconImageSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+FaviconImageSpecificsToValue(
const sync_pb::FaviconImageSpecifics& favicon_image_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* FaviconTrackingSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+FaviconTrackingSpecificsToValue(
const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics);
-SYNC_EXPORT base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue(
+SYNC_EXPORT scoped_ptr<base::DictionaryValue>
+HistoryDeleteDirectiveSpecificsToValue(
const sync_pb::HistoryDeleteDirectiveSpecifics&
history_delete_directive_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSettingSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ManagedUserSettingSpecificsToValue(
const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ManagedUserSpecificsToValue(
const sync_pb::ManagedUserSpecifics& managed_user_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue*
- ManagedUserSharedSettingSpecificsToValue(
- const sync_pb::ManagedUserSharedSettingSpecifics&
- managed_user_shared_setting_specifics);
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ManagedUserSharedSettingSpecificsToValue(
+ const sync_pb::ManagedUserSharedSettingSpecifics&
+ managed_user_shared_setting_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserWhitelistSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ManagedUserWhitelistSpecificsToValue(
const sync_pb::ManagedUserWhitelistSpecifics&
managed_user_whitelist_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* MediaToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> MediaToValue(
const sync_pb::Media& media);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* NigoriSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> NigoriSpecificsToValue(
const sync_pb::NigoriSpecifics& nigori_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> PasswordSpecificsToValue(
const sync_pb::PasswordSpecifics& password_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* PreferenceSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+PreferenceSpecificsToValue(
const sync_pb::PreferenceSpecifics& password_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue*
- SyncedNotificationAppInfoSpecificsToValue(
- const sync_pb::SyncedNotificationAppInfoSpecifics&
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+SyncedNotificationAppInfoSpecificsToValue(
+ const sync_pb::SyncedNotificationAppInfoSpecifics&
synced_notification_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationSpecificsToValue(
- const sync_pb::SyncedNotificationSpecifics&
- synced_notification_specifics);
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+SyncedNotificationSpecificsToValue(
+ const sync_pb::SyncedNotificationSpecifics& synced_notification_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SearchEngineSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+SearchEngineSpecificsToValue(
const sync_pb::SearchEngineSpecifics& search_engine_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ThemeSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ThemeSpecificsToValue(
const sync_pb::ThemeSpecifics& theme_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* TypedUrlSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> TypedUrlSpecificsToValue(
const sync_pb::TypedUrlSpecifics& typed_url_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* WalletMaskedCreditCardToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+WalletMaskedCreditCardToValue(
const sync_pb::WalletMaskedCreditCard& wallet_masked_card);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* WalletPostalAddressToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+WalletPostalAddressToValue(
const sync_pb::WalletPostalAddress& wallet_postal_address);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* WifiCredentialSpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+WifiCredentialSpecificsToValue(
const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics);
// Any present extensions are mapped to sub-dictionary values with the
// key equal to the extension name.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* EntitySpecificsToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> EntitySpecificsToValue(
const sync_pb::EntitySpecifics& specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncEntityToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SyncEntityToValue(
const sync_pb::SyncEntity& entity,
bool include_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ClientToServerMessageToValue(
- const sync_pb::ClientToServerMessage& proto,
- bool include_specifics);
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ClientToServerMessageToValue(const sync_pb::ClientToServerMessage& proto,
+ bool include_specifics);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ClientToServerResponseToValue(
- const sync_pb::ClientToServerResponse& proto,
- bool include_specifics);
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ClientToServerResponseToValue(const sync_pb::ClientToServerResponse& proto,
+ bool include_specifics);
-base::DictionaryValue* DatatypeAssociationStatsToValue(
+scoped_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue(
const sync_pb::DatatypeAssociationStats& proto);
-base::DictionaryValue* DebugEventInfoToValue(
+scoped_ptr<base::DictionaryValue> DebugEventInfoToValue(
const sync_pb::DebugEventInfo& proto);
-base::DictionaryValue* DebugInfoToValue(
+scoped_ptr<base::DictionaryValue> DebugInfoToValue(
const sync_pb::DebugInfo& proto);
-base::DictionaryValue* SyncCycleCompletedEventInfoToValue(
+scoped_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue(
const sync_pb::SyncCycleCompletedEventInfo& proto);
-base::DictionaryValue* ClientConfigParamsToValue(
+scoped_ptr<base::DictionaryValue> ClientConfigParamsToValue(
const sync_pb::ClientConfigParams& proto);
-SYNC_EXPORT_PRIVATE base::DictionaryValue* AttachmentIdProtoToValue(
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AttachmentIdProtoToValue(
const sync_pb::AttachmentIdProto& proto);
} // namespace syncer
diff --git a/sync/protocol/proto_value_conversions_unittest.cc b/sync/protocol/proto_value_conversions_unittest.cc
index 47eb940..e28deb0 100644
--- a/sync/protocol/proto_value_conversions_unittest.cc
+++ b/sync/protocol/proto_value_conversions_unittest.cc
@@ -46,9 +46,9 @@ class ProtoValueConversionsTest : public testing::Test {
protected:
template <class T>
void TestSpecificsToValue(
- base::DictionaryValue* (*specifics_to_value)(const T&)) {
+ scoped_ptr<base::DictionaryValue>(*specifics_to_value)(const T&)) {
const T& specifics(T::default_instance());
- scoped_ptr<base::DictionaryValue> value(specifics_to_value(specifics));
+ scoped_ptr<base::DictionaryValue> value = specifics_to_value(specifics);
// We can't do much but make sure that this doesn't crash.
}
};