summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sync/api/sync_change_unittest.cc8
-rw-r--r--sync/engine/non_blocking_type_commit_contribution.cc1
-rw-r--r--sync/engine/traffic_logger.cc7
-rw-r--r--sync/internal_api/change_record.cc7
-rw-r--r--sync/internal_api/public/base/model_type.h5
-rw-r--r--sync/internal_api/public/change_record.h7
-rw-r--r--sync/internal_api/public/change_record_unittest.cc46
-rw-r--r--sync/internal_api/public/engine/model_safe_worker.cc8
-rw-r--r--sync/internal_api/public/engine/model_safe_worker.h5
-rw-r--r--sync/internal_api/public/sessions/sync_session_snapshot.cc14
-rw-r--r--sync/internal_api/public/sessions/sync_session_snapshot.h3
-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
-rw-r--r--sync/syncable/entry_kernel.cc4
-rw-r--r--sync/syncable/model_type.cc6
-rw-r--r--sync/syncable/model_type_unittest.cc2
17 files changed, 343 insertions, 304 deletions
diff --git a/sync/api/sync_change_unittest.cc b/sync/api/sync_change_unittest.cc
index 24a14b6..919fe53 100644
--- a/sync/api/sync_change_unittest.cc
+++ b/sync/api/sync_change_unittest.cc
@@ -142,16 +142,16 @@ TEST_F(SyncChangeTest, SyncerChanges) {
e = change_list[1];
EXPECT_EQ(SyncChange::ACTION_ADD, e.change_type());
EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType());
- ref_spec.reset(EntitySpecificsToValue(add_specifics));
- e_spec.reset(EntitySpecificsToValue(e.sync_data().GetSpecifics()));
+ ref_spec = EntitySpecificsToValue(add_specifics);
+ e_spec = EntitySpecificsToValue(e.sync_data().GetSpecifics());
EXPECT_TRUE(ref_spec->Equals(e_spec.get()));
// Verify delete.
e = change_list[2];
EXPECT_EQ(SyncChange::ACTION_DELETE, e.change_type());
EXPECT_EQ(PREFERENCES, e.sync_data().GetDataType());
- ref_spec.reset(EntitySpecificsToValue(delete_specifics));
- e_spec.reset(EntitySpecificsToValue(e.sync_data().GetSpecifics()));
+ ref_spec = EntitySpecificsToValue(delete_specifics);
+ e_spec = EntitySpecificsToValue(e.sync_data().GetSpecifics());
EXPECT_TRUE(ref_spec->Equals(e_spec.get()));
}
diff --git a/sync/engine/non_blocking_type_commit_contribution.cc b/sync/engine/non_blocking_type_commit_contribution.cc
index baa0325..5df159f 100644
--- a/sync/engine/non_blocking_type_commit_contribution.cc
+++ b/sync/engine/non_blocking_type_commit_contribution.cc
@@ -4,6 +4,7 @@
#include "sync/engine/non_blocking_type_commit_contribution.h"
+#include "base/values.h"
#include "sync/engine/model_type_sync_worker_impl.h"
#include "sync/internal_api/public/non_blocking_sync_common.h"
#include "sync/protocol/proto_value_conversions.h"
diff --git a/sync/engine/traffic_logger.cc b/sync/engine/traffic_logger.cc
index 13b1c64..bc285bd 100644
--- a/sync/engine/traffic_logger.cc
+++ b/sync/engine/traffic_logger.cc
@@ -18,11 +18,12 @@ namespace syncer {
namespace {
template <class T>
void LogData(const T& data,
- base::DictionaryValue* (*to_dictionary_value)(const T&, bool),
+ scoped_ptr<base::DictionaryValue>(*to_dictionary_value)(const T&,
+ bool),
const std::string& description) {
if (::logging::DEBUG_MODE && VLOG_IS_ON(1)) {
- scoped_ptr<base::DictionaryValue> value(
- (*to_dictionary_value)(data, true /* include_specifics */));
+ scoped_ptr<base::DictionaryValue> value =
+ (*to_dictionary_value)(data, true /* include_specifics */);
std::string message;
base::JSONWriter::WriteWithOptions(value.get(),
base::JSONWriter::OPTIONS_PRETTY_PRINT,
diff --git a/sync/internal_api/change_record.cc b/sync/internal_api/change_record.cc
index 4894b3c..d6c7d36 100644
--- a/sync/internal_api/change_record.cc
+++ b/sync/internal_api/change_record.cc
@@ -17,8 +17,8 @@ ChangeRecord::ChangeRecord()
ChangeRecord::~ChangeRecord() {}
-base::DictionaryValue* ChangeRecord::ToValue() const {
- base::DictionaryValue* value = new base::DictionaryValue();
+scoped_ptr<base::DictionaryValue> ChangeRecord::ToValue() const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
std::string action_str;
switch (action) {
case ACTION_ADD:
@@ -55,7 +55,8 @@ ExtraPasswordChangeRecordData::ExtraPasswordChangeRecordData(
ExtraPasswordChangeRecordData::~ExtraPasswordChangeRecordData() {}
-base::DictionaryValue* ExtraPasswordChangeRecordData::ToValue() const {
+scoped_ptr<base::DictionaryValue> ExtraPasswordChangeRecordData::ToValue()
+ const {
return PasswordSpecificsDataToValue(unencrypted_);
}
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index 2bba5d5..0639181 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -14,6 +14,7 @@
#include <string>
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/enum_set.h"
@@ -292,8 +293,8 @@ SYNC_EXPORT std::string ModelTypeSetToString(ModelTypeSet model_types);
SYNC_EXPORT ModelTypeSet ModelTypeSetFromString(
const std::string& model_type_string);
-// Caller takes ownership of returned list.
-SYNC_EXPORT base::ListValue* ModelTypeSetToValue(ModelTypeSet model_types);
+SYNC_EXPORT scoped_ptr<base::ListValue> ModelTypeSetToValue(
+ ModelTypeSet model_types);
SYNC_EXPORT ModelTypeSet ModelTypeSetFromValue(const base::ListValue& value);
diff --git a/sync/internal_api/public/change_record.h b/sync/internal_api/public/change_record.h
index 062d6fa..9f51737 100644
--- a/sync/internal_api/public/change_record.h
+++ b/sync/internal_api/public/change_record.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/scoped_ptr.h"
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/util/immutable.h"
#include "sync/protocol/password_specifics.pb.h"
@@ -29,8 +30,7 @@ class SYNC_EXPORT ExtraPasswordChangeRecordData {
const sync_pb::PasswordSpecificsData& data);
virtual ~ExtraPasswordChangeRecordData();
- // Transfers ownership of the DictionaryValue to the caller.
- virtual base::DictionaryValue* ToValue() const;
+ virtual scoped_ptr<base::DictionaryValue> ToValue() const;
const sync_pb::PasswordSpecificsData& unencrypted() const;
private:
@@ -50,8 +50,7 @@ struct SYNC_EXPORT_PRIVATE ChangeRecord {
ChangeRecord();
~ChangeRecord();
- // Transfers ownership of the DictionaryValue to the caller.
- base::DictionaryValue* ToValue() const;
+ scoped_ptr<base::DictionaryValue> ToValue() const;
int64 id;
Action action;
diff --git a/sync/internal_api/public/change_record_unittest.cc b/sync/internal_api/public/change_record_unittest.cc
index 3d532d6..f12974e 100644
--- a/sync/internal_api/public/change_record_unittest.cc
+++ b/sync/internal_api/public/change_record_unittest.cc
@@ -53,7 +53,7 @@ void CheckChangeRecordValue(
if (record.action == ChangeRecord::ACTION_DELETE) {
scoped_ptr<base::DictionaryValue> expected_extra_value;
if (record.extra.get()) {
- expected_extra_value.reset(record.extra->ToValue());
+ expected_extra_value = record.extra->ToValue();
}
const base::Value* extra_value = NULL;
EXPECT_EQ(record.extra.get() != NULL,
@@ -67,10 +67,32 @@ void CheckChangeRecordValue(
}
}
-class MockExtraChangeRecordData
- : public ExtraPasswordChangeRecordData {
+class TestExtraChangeRecordData : public ExtraPasswordChangeRecordData {
public:
- MOCK_CONST_METHOD0(ToValue, base::DictionaryValue*());
+ TestExtraChangeRecordData()
+ : to_value_calls_(0), expected_to_value_calls_(0) {}
+
+ ~TestExtraChangeRecordData() override {
+ EXPECT_EQ(expected_to_value_calls_, to_value_calls_);
+ }
+
+ scoped_ptr<base::DictionaryValue> ToValue() const override {
+ const_cast<TestExtraChangeRecordData*>(this)->to_value_calls_++;
+ return dict_->CreateDeepCopy();
+ }
+
+ void set_dictionary_value(scoped_ptr<base::DictionaryValue> dict) {
+ dict_ = dict.Pass();
+ }
+
+ void set_expected_to_value_calls(size_t expectation) {
+ expected_to_value_calls_ = expectation;
+ }
+
+ private:
+ scoped_ptr<base::DictionaryValue> dict_;
+ size_t to_value_calls_;
+ size_t expected_to_value_calls_;
};
TEST_F(ChangeRecordTest, ChangeRecordToValue) {
@@ -87,7 +109,7 @@ TEST_F(ChangeRecordTest, ChangeRecordToValue) {
record.action = ChangeRecord::ACTION_ADD;
record.id = kTestId;
record.specifics = old_specifics;
- record.extra.reset(new StrictMock<MockExtraChangeRecordData>());
+ record.extra.reset(new TestExtraChangeRecordData());
scoped_ptr<base::DictionaryValue> value(record.ToValue());
CheckChangeRecordValue(record, *value);
}
@@ -98,7 +120,7 @@ TEST_F(ChangeRecordTest, ChangeRecordToValue) {
record.action = ChangeRecord::ACTION_UPDATE;
record.id = kTestId;
record.specifics = old_specifics;
- record.extra.reset(new StrictMock<MockExtraChangeRecordData>());
+ record.extra.reset(new TestExtraChangeRecordData());
scoped_ptr<base::DictionaryValue> value(record.ToValue());
CheckChangeRecordValue(record, *value);
}
@@ -120,12 +142,12 @@ TEST_F(ChangeRecordTest, ChangeRecordToValue) {
record.id = kTestId;
record.specifics = old_specifics;
- base::DictionaryValue extra_value;
- extra_value.SetString("foo", "bar");
- scoped_ptr<StrictMock<MockExtraChangeRecordData> > extra(
- new StrictMock<MockExtraChangeRecordData>());
- EXPECT_CALL(*extra, ToValue()).Times(2).WillRepeatedly(
- Invoke(&extra_value, &base::DictionaryValue::DeepCopy));
+ scoped_ptr<base::DictionaryValue> extra_value(new base::DictionaryValue());
+ extra_value->SetString("foo", "bar");
+ scoped_ptr<TestExtraChangeRecordData> extra(
+ new TestExtraChangeRecordData());
+ extra->set_dictionary_value(extra_value.Pass());
+ extra->set_expected_to_value_calls(2U);
record.extra.reset(extra.release());
scoped_ptr<base::DictionaryValue> value(record.ToValue());
diff --git a/sync/internal_api/public/engine/model_safe_worker.cc b/sync/internal_api/public/engine/model_safe_worker.cc
index ea8bd4b..9692a78 100644
--- a/sync/internal_api/public/engine/model_safe_worker.cc
+++ b/sync/internal_api/public/engine/model_safe_worker.cc
@@ -11,9 +11,9 @@
namespace syncer {
-base::DictionaryValue* ModelSafeRoutingInfoToValue(
+scoped_ptr<base::DictionaryValue> ModelSafeRoutingInfoToValue(
const ModelSafeRoutingInfo& routing_info) {
- base::DictionaryValue* dict = new base::DictionaryValue();
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
it != routing_info.end(); ++it) {
dict->SetString(ModelTypeToString(it->first),
@@ -24,8 +24,8 @@ base::DictionaryValue* ModelSafeRoutingInfoToValue(
std::string ModelSafeRoutingInfoToString(
const ModelSafeRoutingInfo& routing_info) {
- scoped_ptr<base::DictionaryValue> dict(
- ModelSafeRoutingInfoToValue(routing_info));
+ scoped_ptr<base::DictionaryValue> dict =
+ ModelSafeRoutingInfoToValue(routing_info);
std::string json;
base::JSONWriter::Write(dict.get(), &json);
return json;
diff --git a/sync/internal_api/public/engine/model_safe_worker.h b/sync/internal_api/public/engine/model_safe_worker.h
index ad84d49..e2d04c2 100644
--- a/sync/internal_api/public/engine/model_safe_worker.h
+++ b/sync/internal_api/public/engine/model_safe_worker.h
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
@@ -148,8 +149,8 @@ class SYNC_EXPORT ModelSafeWorker
typedef std::map<ModelType, ModelSafeGroup> ModelSafeRoutingInfo;
// Caller takes ownership of return value.
-SYNC_EXPORT_PRIVATE base::DictionaryValue* ModelSafeRoutingInfoToValue(
- const ModelSafeRoutingInfo& routing_info);
+SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
+ModelSafeRoutingInfoToValue(const ModelSafeRoutingInfo& routing_info);
SYNC_EXPORT std::string ModelSafeRoutingInfoToString(
const ModelSafeRoutingInfo& routing_info);
diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.cc b/sync/internal_api/public/sessions/sync_session_snapshot.cc
index 4e7a2b1..3380882 100644
--- a/sync/internal_api/public/sessions/sync_session_snapshot.cc
+++ b/sync/internal_api/public/sessions/sync_session_snapshot.cc
@@ -54,7 +54,7 @@ SyncSessionSnapshot::SyncSessionSnapshot(
SyncSessionSnapshot::~SyncSessionSnapshot() {}
-base::DictionaryValue* SyncSessionSnapshot::ToValue() const {
+scoped_ptr<base::DictionaryValue> SyncSessionSnapshot::ToValue() const {
scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
value->SetInteger("numSuccessfulCommits",
model_neutral_state_.num_successful_commits);
@@ -71,7 +71,7 @@ base::DictionaryValue* SyncSessionSnapshot::ToValue() const {
value->SetInteger("numServerOverwrites",
model_neutral_state_.num_server_overwrites);
value->Set("downloadProgressMarkers",
- ProgressMarkerMapToValue(download_progress_markers_).release());
+ ProgressMarkerMapToValue(download_progress_markers_));
value->SetBoolean("isSilenced", is_silenced_);
// We don't care too much if we lose precision here, also.
value->SetInteger("numEncryptionConflicts",
@@ -96,16 +96,14 @@ base::DictionaryValue* SyncSessionSnapshot::ToValue() const {
const std::string model_type = ModelTypeToString(static_cast<ModelType>(i));
counter_entries->Set(model_type, type_entries.release());
}
- value->Set("counter_entries", counter_entries.release());
- return value.release();
+ value->Set("counter_entries", counter_entries.Pass());
+ return value;
}
std::string SyncSessionSnapshot::ToString() const {
- scoped_ptr<base::DictionaryValue> value(ToValue());
std::string json;
- base::JSONWriter::WriteWithOptions(value.get(),
- base::JSONWriter::OPTIONS_PRETTY_PRINT,
- &json);
+ base::JSONWriter::WriteWithOptions(
+ ToValue().get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
return json;
}
diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.h b/sync/internal_api/public/sessions/sync_session_snapshot.h
index a764de1..8641fbd 100644
--- a/sync/internal_api/public/sessions/sync_session_snapshot.h
+++ b/sync/internal_api/public/sessions/sync_session_snapshot.h
@@ -44,8 +44,7 @@ class SYNC_EXPORT SyncSessionSnapshot {
sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source);
~SyncSessionSnapshot();
- // Caller takes ownership of the returned dictionary.
- base::DictionaryValue* ToValue() const;
+ scoped_ptr<base::DictionaryValue> ToValue() const;
std::string ToString() const;
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.
}
};
diff --git a/sync/syncable/entry_kernel.cc b/sync/syncable/entry_kernel.cc
index ba0739b..c51b1a6 100644
--- a/sync/syncable/entry_kernel.cc
+++ b/sync/syncable/entry_kernel.cc
@@ -95,7 +95,7 @@ void SetEncryptableProtoValues(
ProtoField field = static_cast<ProtoField>(i);
const std::string& key = GetProtoFieldString(field);
- base::DictionaryValue* value = NULL;
+ scoped_ptr<base::DictionaryValue> value;
sync_pb::EntitySpecifics decrypted;
const sync_pb::EncryptedData& encrypted = kernel.ref(field).encrypted();
if (cryptographer &&
@@ -107,7 +107,7 @@ void SetEncryptableProtoValues(
} else {
value = EntitySpecificsToValue(kernel.ref(field));
}
- dictionary_value->Set(key, value);
+ dictionary_value->Set(key, value.Pass());
}
}
diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc
index 806b6f2..cfe5c2f 100644
--- a/sync/syncable/model_type.cc
+++ b/sync/syncable/model_type.cc
@@ -824,10 +824,10 @@ ModelTypeSet ModelTypeSetFromString(const std::string& model_types_string) {
return model_types;
}
-base::ListValue* ModelTypeSetToValue(ModelTypeSet model_types) {
- base::ListValue* value = new base::ListValue();
+scoped_ptr<base::ListValue> ModelTypeSetToValue(ModelTypeSet model_types) {
+ scoped_ptr<base::ListValue> value(new base::ListValue());
for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) {
- value->Append(new base::StringValue(ModelTypeToString(it.Get())));
+ value->AppendString(ModelTypeToString(it.Get()));
}
return value;
}
diff --git a/sync/syncable/model_type_unittest.cc b/sync/syncable/model_type_unittest.cc
index 2869f31..05692c0 100644
--- a/sync/syncable/model_type_unittest.cc
+++ b/sync/syncable/model_type_unittest.cc
@@ -58,7 +58,7 @@ TEST_F(ModelTypeTest, ModelTypeSetFromValue) {
// Now try with a few random types.
model_types.Put(BOOKMARKS);
model_types.Put(APPS);
- value.reset(ModelTypeSetToValue(model_types));
+ value = ModelTypeSetToValue(model_types);
EXPECT_TRUE(model_types.Equals(ModelTypeSetFromValue(*value)));
}