summaryrefslogtreecommitdiff
path: root/chromium/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/dbus')
-rw-r--r--chromium/dbus/BUILD.gn3
-rw-r--r--chromium/dbus/OWNERS1
-rw-r--r--chromium/dbus/bus.cc8
-rw-r--r--chromium/dbus/file_descriptor.h6
-rw-r--r--chromium/dbus/test_service.cc3
-rw-r--r--chromium/dbus/values_util.cc53
-rw-r--r--chromium/dbus/values_util.h5
-rw-r--r--chromium/dbus/values_util_unittest.cc115
8 files changed, 104 insertions, 90 deletions
diff --git a/chromium/dbus/BUILD.gn b/chromium/dbus/BUILD.gn
index 1502ca75361..ed113c85421 100644
--- a/chromium/dbus/BUILD.gn
+++ b/chromium/dbus/BUILD.gn
@@ -2,9 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/features.gni")
import("//testing/test.gni")
import("//third_party/protobuf/proto_library.gni")
+assert(use_dbus)
+
component("dbus") {
sources = [
"bus.cc",
diff --git a/chromium/dbus/OWNERS b/chromium/dbus/OWNERS
index fc425e6db42..04931c39c3f 100644
--- a/chromium/dbus/OWNERS
+++ b/chromium/dbus/OWNERS
@@ -1,4 +1,3 @@
hashimoto@chromium.org
-keybuk@chromium.org
satorux@chromium.org
stevenjb@chromium.org
diff --git a/chromium/dbus/bus.cc b/chromium/dbus/bus.cc
index 1827928b9e0..d6e2c5b6401 100644
--- a/chromium/dbus/bus.cc
+++ b/chromium/dbus/bus.cc
@@ -13,6 +13,7 @@
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
@@ -189,7 +190,8 @@ Bus::Bus(const Options& options)
: bus_type_(options.bus_type),
connection_type_(options.connection_type),
dbus_task_runner_(options.dbus_task_runner),
- on_shutdown_(false /* manual_reset */, false /* initially_signaled */),
+ on_shutdown_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
connection_(NULL),
origin_thread_id_(base::PlatformThread::CurrentId()),
async_operations_set_up_(false),
@@ -201,8 +203,8 @@ Bus::Bus(const Options& options)
dbus_threads_init_default();
// The origin message loop is unnecessary if the client uses synchronous
// functions only.
- if (base::MessageLoop::current())
- origin_task_runner_ = base::MessageLoop::current()->task_runner();
+ if (base::ThreadTaskRunnerHandle::IsSet())
+ origin_task_runner_ = base::ThreadTaskRunnerHandle::Get();
}
Bus::~Bus() {
diff --git a/chromium/dbus/file_descriptor.h b/chromium/dbus/file_descriptor.h
index 8fcab2f440f..f8e86777eaf 100644
--- a/chromium/dbus/file_descriptor.h
+++ b/chromium/dbus/file_descriptor.h
@@ -7,7 +7,7 @@
#include <memory>
-#include "base/move.h"
+#include "base/macros.h"
#include "dbus/dbus_export.h"
namespace dbus {
@@ -34,8 +34,6 @@ namespace dbus {
// also allows the caller to do this work on the File thread to conform
// with i/o restrictions.
class CHROME_DBUS_EXPORT FileDescriptor {
- MOVE_ONLY_TYPE_FOR_CPP_03(FileDescriptor);
-
public:
// This provides a simple way to pass around file descriptors since they must
// be closed on a thread that is allowed to perform I/O.
@@ -82,6 +80,8 @@ class CHROME_DBUS_EXPORT FileDescriptor {
int value_;
bool owner_;
bool valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileDescriptor);
};
using ScopedFileDescriptor =
diff --git a/chromium/dbus/test_service.cc b/chromium/dbus/test_service.cc
index 217e8ee7591..6445f6a6467 100644
--- a/chromium/dbus/test_service.cc
+++ b/chromium/dbus/test_service.cc
@@ -45,7 +45,8 @@ TestService::TestService(const Options& options)
service_name_(options.service_name),
request_ownership_options_(options.request_ownership_options),
dbus_task_runner_(options.dbus_task_runner),
- on_name_obtained_(false, false),
+ on_name_obtained_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ base::WaitableEvent::InitialState::NOT_SIGNALED),
num_exported_methods_(0),
send_immediate_properties_changed_(false),
has_ownership_(false),
diff --git a/chromium/dbus/values_util.cc b/chromium/dbus/values_util.cc
index ed435a19368..bea7bea7462 100644
--- a/chromium/dbus/values_util.cc
+++ b/chromium/dbus/values_util.cc
@@ -4,10 +4,11 @@
#include "dbus/values_util.h"
-#include <memory>
+#include <utility>
#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "dbus/message.h"
@@ -24,10 +25,10 @@ bool IsExactlyRepresentableByDouble(T value) {
// Pops values from |reader| and appends them to |list_value|.
bool PopListElements(MessageReader* reader, base::ListValue* list_value) {
while (reader->HasMoreData()) {
- base::Value* element_value = PopDataAsValue(reader);
+ std::unique_ptr<base::Value> element_value = PopDataAsValue(reader);
if (!element_value)
return false;
- list_value->Append(element_value);
+ list_value->Append(std::move(element_value));
}
return true;
}
@@ -55,10 +56,10 @@ bool PopDictionaryEntries(MessageReader* reader,
base::JSONWriter::Write(*key, &key_string);
}
// Get the value and set the key-value pair.
- base::Value* value = PopDataAsValue(&entry_reader);
+ std::unique_ptr<base::Value> value = PopDataAsValue(&entry_reader);
if (!value)
return false;
- dictionary_value->SetWithoutPathExpansion(key_string, value);
+ dictionary_value->SetWithoutPathExpansion(key_string, std::move(value));
}
return true;
}
@@ -88,8 +89,8 @@ std::string GetTypeSignature(const base::Value& value) {
} // namespace
-base::Value* PopDataAsValue(MessageReader* reader) {
- base::Value* result = NULL;
+std::unique_ptr<base::Value> PopDataAsValue(MessageReader* reader) {
+ std::unique_ptr<base::Value> result;
switch (reader->GetDataType()) {
case Message::INVALID_DATA:
// Do nothing.
@@ -97,37 +98,39 @@ base::Value* PopDataAsValue(MessageReader* reader) {
case Message::BYTE: {
uint8_t value = 0;
if (reader->PopByte(&value))
- result = new base::FundamentalValue(value);
+ result = base::MakeUnique<base::FundamentalValue>(value);
break;
}
case Message::BOOL: {
bool value = false;
if (reader->PopBool(&value))
- result = new base::FundamentalValue(value);
+ result = base::MakeUnique<base::FundamentalValue>(value);
break;
}
case Message::INT16: {
int16_t value = 0;
if (reader->PopInt16(&value))
- result = new base::FundamentalValue(value);
+ result = base::MakeUnique<base::FundamentalValue>(value);
break;
}
case Message::UINT16: {
uint16_t value = 0;
if (reader->PopUint16(&value))
- result = new base::FundamentalValue(value);
+ result = base::MakeUnique<base::FundamentalValue>(value);
break;
}
case Message::INT32: {
int32_t value = 0;
if (reader->PopInt32(&value))
- result = new base::FundamentalValue(value);
+ result = base::MakeUnique<base::FundamentalValue>(value);
break;
}
case Message::UINT32: {
uint32_t value = 0;
- if (reader->PopUint32(&value))
- result = new base::FundamentalValue(static_cast<double>(value));
+ if (reader->PopUint32(&value)) {
+ result = base::MakeUnique<base::FundamentalValue>(
+ static_cast<double>(value));
+ }
break;
}
case Message::INT64: {
@@ -135,7 +138,8 @@ base::Value* PopDataAsValue(MessageReader* reader) {
if (reader->PopInt64(&value)) {
DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
value << " is not exactly representable by double";
- result = new base::FundamentalValue(static_cast<double>(value));
+ result = base::MakeUnique<base::FundamentalValue>(
+ static_cast<double>(value));
}
break;
}
@@ -144,26 +148,27 @@ base::Value* PopDataAsValue(MessageReader* reader) {
if (reader->PopUint64(&value)) {
DLOG_IF(WARNING, !IsExactlyRepresentableByDouble(value)) <<
value << " is not exactly representable by double";
- result = new base::FundamentalValue(static_cast<double>(value));
+ result = base::MakeUnique<base::FundamentalValue>(
+ static_cast<double>(value));
}
break;
}
case Message::DOUBLE: {
double value = 0;
if (reader->PopDouble(&value))
- result = new base::FundamentalValue(value);
+ result = base::MakeUnique<base::FundamentalValue>(value);
break;
}
case Message::STRING: {
std::string value;
if (reader->PopString(&value))
- result = new base::StringValue(value);
+ result = base::MakeUnique<base::StringValue>(value);
break;
}
case Message::OBJECT_PATH: {
ObjectPath value;
if (reader->PopObjectPath(&value))
- result = new base::StringValue(value.value());
+ result = base::MakeUnique<base::StringValue>(value.value());
break;
}
case Message::UNIX_FD: {
@@ -180,11 +185,11 @@ base::Value* PopDataAsValue(MessageReader* reader) {
std::unique_ptr<base::DictionaryValue> dictionary_value(
new base::DictionaryValue);
if (PopDictionaryEntries(&sub_reader, dictionary_value.get()))
- result = dictionary_value.release();
+ result = std::move(dictionary_value);
} else {
std::unique_ptr<base::ListValue> list_value(new base::ListValue);
if (PopListElements(&sub_reader, list_value.get()))
- result = list_value.release();
+ result = std::move(list_value);
}
}
break;
@@ -194,7 +199,7 @@ base::Value* PopDataAsValue(MessageReader* reader) {
if (reader->PopStruct(&sub_reader)) {
std::unique_ptr<base::ListValue> list_value(new base::ListValue);
if (PopListElements(&sub_reader, list_value.get()))
- result = list_value.release();
+ result = std::move(list_value);
}
break;
}
@@ -279,9 +284,7 @@ void AppendValueData(MessageWriter* writer, const base::Value& value) {
value.GetAsList(&list);
dbus::MessageWriter array_writer(NULL);
writer->OpenArray("v", &array_writer);
- for (base::ListValue::const_iterator iter = list->begin();
- iter != list->end(); ++iter) {
- const base::Value* value = *iter;
+ for (const auto& value : *list) {
AppendValueDataAsVariant(&array_writer, *value);
}
writer->CloseContainer(&array_writer);
diff --git a/chromium/dbus/values_util.h b/chromium/dbus/values_util.h
index b6f4ff3b10e..81b839b1882 100644
--- a/chromium/dbus/values_util.h
+++ b/chromium/dbus/values_util.h
@@ -7,6 +7,8 @@
#include <stdint.h>
+#include <memory>
+
#include "dbus/dbus_export.h"
namespace base {
@@ -22,7 +24,8 @@ class MessageWriter;
// Returns NULL if an error occurs.
// Note: Integer values larger than int32_t (including uint32_t) are converted
// to double. Non-string dictionary keys are converted to strings.
-CHROME_DBUS_EXPORT base::Value* PopDataAsValue(MessageReader* reader);
+CHROME_DBUS_EXPORT std::unique_ptr<base::Value> PopDataAsValue(
+ MessageReader* reader);
// Appends a basic type value to |writer|. Basic types are BOOLEAN, INTEGER,
// DOUBLE, and STRING. Use this function for values that are known to be basic
diff --git a/chromium/dbus/values_util_unittest.cc b/chromium/dbus/values_util_unittest.cc
index 6903d51d20d..d310d68a485 100644
--- a/chromium/dbus/values_util_unittest.cc
+++ b/chromium/dbus/values_util_unittest.cc
@@ -9,6 +9,7 @@
#include <cmath>
#include <memory>
+#include <utility>
#include <vector>
#include "base/json/json_writer.h"
@@ -52,65 +53,65 @@ TEST(ValuesUtilTest, PopBasicTypes) {
std::unique_ptr<base::Value> value;
std::unique_ptr<base::Value> expected_value;
// Pop a byte.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kByteValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a bool.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kBoolValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop an int16_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kInt16Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a uint16_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kUint16Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop an int32_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kInt32Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a uint32_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kUint32Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop an int64_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kInt64Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a uint64_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kUint64Value)));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a double.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kDoubleValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a string.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::StringValue(kStringValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop an empty string.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::StringValue(kEmptyStringValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop an object path.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::StringValue(kObjectPathValue.value()));
EXPECT_TRUE(value->Equals(expected_value.get()));
@@ -133,22 +134,22 @@ TEST(ValuesUtilTest, PopVariant) {
std::unique_ptr<base::Value> value;
std::unique_ptr<base::Value> expected_value;
// Pop a bool.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kBoolValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop an int32_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kInt32Value));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a double.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::FundamentalValue(kDoubleValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
// Pop a string.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(new base::StringValue(kStringValue));
EXPECT_TRUE(value->Equals(expected_value.get()));
@@ -170,7 +171,7 @@ TEST(ValuesUtilTest, PopExtremelyLargeIntegers) {
std::unique_ptr<base::Value> expected_value;
double double_value = 0;
// Pop an int64_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kInt64Value)));
@@ -178,7 +179,7 @@ TEST(ValuesUtilTest, PopExtremelyLargeIntegers) {
ASSERT_TRUE(value->GetAsDouble(&double_value));
EXPECT_NE(kInt64Value, static_cast<int64_t>(double_value));
// Pop a uint64_t.
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
expected_value.reset(
new base::FundamentalValue(static_cast<double>(kUint64Value)));
@@ -204,7 +205,7 @@ TEST(ValuesUtilTest, PopIntArray) {
// Create the expected value.
std::unique_ptr<base::ListValue> list_value(new base::ListValue);
for (size_t i = 0; i != data.size(); ++i)
- list_value->Append(new base::FundamentalValue(data[i]));
+ list_value->AppendInteger(data[i]);
// Pop an int32_t array.
MessageReader reader(response.get());
@@ -227,7 +228,7 @@ TEST(ValuesUtilTest, PopStringArray) {
// Create the expected value.
std::unique_ptr<base::ListValue> list_value(new base::ListValue);
for (size_t i = 0; i != data.size(); ++i)
- list_value->Append(new base::StringValue(data[i]));
+ list_value->AppendString(data[i]);
// Pop a string array.
MessageReader reader(response.get());
@@ -254,10 +255,10 @@ TEST(ValuesUtilTest, PopStruct) {
// Create the expected value.
base::ListValue list_value;
- list_value.Append(new base::FundamentalValue(kBoolValue));
- list_value.Append(new base::FundamentalValue(kInt32Value));
- list_value.Append(new base::FundamentalValue(kDoubleValue));
- list_value.Append(new base::StringValue(kStringValue));
+ list_value.AppendBoolean(kBoolValue);
+ list_value.AppendInteger(kInt32Value);
+ list_value.AppendDouble(kDoubleValue);
+ list_value.AppendString(kStringValue);
// Pop a struct.
MessageReader reader(response.get());
@@ -408,16 +409,16 @@ TEST(ValuesUtilTest, AppendBasicTypes) {
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kIntegerValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kDoubleValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kStringValue));
}
@@ -437,16 +438,16 @@ TEST(ValuesUtilTest, AppendBasicTypesAsVariant) {
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kIntegerValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kDoubleValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kStringValue));
}
@@ -466,16 +467,16 @@ TEST(ValuesUtilTest, AppendValueDataBasicTypes) {
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kIntegerValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kDoubleValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kStringValue));
}
@@ -495,16 +496,16 @@ TEST(ValuesUtilTest, AppendValueDataAsVariantBasicTypes) {
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kIntegerValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kDoubleValue));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kStringValue));
}
@@ -548,10 +549,10 @@ TEST(ValuesUtilTest, AppendDictionary) {
// Read the data.
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_dictionary));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&int_value));
}
@@ -595,10 +596,10 @@ TEST(ValuesUtilTest, AppendDictionaryAsVariant) {
// Read the data.
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_dictionary));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&int_value));
}
@@ -613,11 +614,12 @@ TEST(ValuesUtilTest, AppendList) {
const double kDoubleValue = 4.9;
const std::string kStringValue = "fifty";
- base::ListValue* list_value = new base::ListValue();
+ std::unique_ptr<base::ListValue> list_value(new base::ListValue());
list_value->AppendBoolean(kBoolValue);
list_value->AppendInteger(kInt32Value);
- base::DictionaryValue* dictionary_value = new base::DictionaryValue();
+ std::unique_ptr<base::DictionaryValue> dictionary_value(
+ new base::DictionaryValue());
dictionary_value->SetBoolean(kKey1, kBoolValue);
dictionary_value->SetInteger(kKey2, kDoubleValue);
@@ -626,8 +628,8 @@ TEST(ValuesUtilTest, AppendList) {
test_list.AppendInteger(kInt32Value);
test_list.AppendDouble(kDoubleValue);
test_list.AppendString(kStringValue);
- test_list.Append(list_value); // takes ownership
- test_list.Append(dictionary_value); // takes ownership
+ test_list.Append(std::move(list_value));
+ test_list.Append(std::move(dictionary_value));
std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
@@ -638,10 +640,10 @@ TEST(ValuesUtilTest, AppendList) {
// Read the data.
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_list));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&int_value));
}
@@ -656,11 +658,12 @@ TEST(ValuesUtilTest, AppendListAsVariant) {
const double kDoubleValue = 4.9;
const std::string kStringValue = "fifty";
- base::ListValue* list_value = new base::ListValue();
+ std::unique_ptr<base::ListValue> list_value(new base::ListValue());
list_value->AppendBoolean(kBoolValue);
list_value->AppendInteger(kInt32Value);
- base::DictionaryValue* dictionary_value = new base::DictionaryValue();
+ std::unique_ptr<base::DictionaryValue> dictionary_value(
+ new base::DictionaryValue());
dictionary_value->SetBoolean(kKey1, kBoolValue);
dictionary_value->SetInteger(kKey2, kDoubleValue);
@@ -669,8 +672,8 @@ TEST(ValuesUtilTest, AppendListAsVariant) {
test_list.AppendInteger(kInt32Value);
test_list.AppendDouble(kDoubleValue);
test_list.AppendString(kStringValue);
- test_list.Append(list_value); // takes ownership
- test_list.Append(dictionary_value); // takes ownership
+ test_list.Append(std::move(list_value));
+ test_list.Append(std::move(dictionary_value));
std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
@@ -681,10 +684,10 @@ TEST(ValuesUtilTest, AppendListAsVariant) {
// Read the data.
MessageReader reader(response.get());
std::unique_ptr<base::Value> value;
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_list));
- value.reset(PopDataAsValue(&reader));
+ value = PopDataAsValue(&reader);
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&int_value));
}