Convert //dbus from scoped_ptr to std::unique_ptr
BUG=554298
R=hashimoto@chromium.org
TBR=scheib@chromium.org
Review URL: https://codereview.chromium.org/1867253002
Cr-Commit-Position: refs/heads/master@{#386236}
CrOS-Libchrome-Original-Commit: 2a193281aac690b3fdfba1246d6b36877553a9be
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 554ccb8..1827928 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -891,7 +891,8 @@
return "";
}
- scoped_ptr<Response> response(Response::FromRawMessage(response_message));
+ std::unique_ptr<Response> response(
+ Response::FromRawMessage(response_message));
MessageReader reader(response.get());
std::string service_owner;
@@ -1114,7 +1115,7 @@
// |message| will be unrefed on exit of the function. Increment the
// reference so we can use it in Signal::FromRawMessage() below.
dbus_message_ref(message);
- scoped_ptr<Signal> signal(Signal::FromRawMessage(message));
+ std::unique_ptr<Signal> signal(Signal::FromRawMessage(message));
// Confirm the validity of the NameOwnerChanged signal.
if (signal->GetMember() != kNameOwnerChangedSignal ||
diff --git a/dbus/bus.h b/dbus/bus.h
index e5e0b1c..7d39159 100644
--- a/dbus/bus.h
+++ b/dbus/bus.h
@@ -88,7 +88,7 @@
// bus.GetObjectProxy(service_name, object_path);
//
// dbus::MethodCall method_call(interface_name, method_name);
-// scoped_ptr<dbus::Response> response(
+// std::unique_ptr<dbus::Response> response(
// object_proxy.CallMethodAndBlock(&method_call, timeout_ms));
// if (response.get() != NULL) { // Success.
// ...
diff --git a/dbus/bus_unittest.cc b/dbus/bus_unittest.cc
index 250717e..84bbb78 100644
--- a/dbus/bus_unittest.cc
+++ b/dbus/bus_unittest.cc
@@ -48,7 +48,7 @@
}
private:
- scoped_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<base::RunLoop> run_loop_;
int expected_quit_calls_;
int actual_quit_calls_;
diff --git a/dbus/dbus_statistics.cc b/dbus/dbus_statistics.cc
index e6eb5a2..e1e0973 100644
--- a/dbus/dbus_statistics.cc
+++ b/dbus/dbus_statistics.cc
@@ -4,11 +4,11 @@
#include "dbus/dbus_statistics.h"
+#include <memory>
#include <set>
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/platform_thread.h"
@@ -108,7 +108,7 @@
const std::string& method,
bool add_stat) {
DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId());
- scoped_ptr<Stat> stat(new Stat(service, interface, method));
+ std::unique_ptr<Stat> stat(new Stat(service, interface, method));
StatSet::iterator found = stats_.find(stat.get());
if (found != stats_.end())
return *found;
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc
index 8f62864..b02b043 100644
--- a/dbus/end_to_end_async_unittest.cc
+++ b/dbus/end_to_end_async_unittest.cc
@@ -5,12 +5,12 @@
#include <stddef.h>
#include <algorithm>
+#include <memory>
#include <string>
#include <vector>
#include "base/bind.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
@@ -255,14 +255,14 @@
}
base::MessageLoop message_loop_;
- scoped_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<base::RunLoop> run_loop_;
std::vector<std::string> response_strings_;
std::vector<std::string> error_names_;
- scoped_ptr<base::Thread> dbus_thread_;
+ std::unique_ptr<base::Thread> dbus_thread_;
scoped_refptr<Bus> bus_;
ObjectProxy* object_proxy_;
ObjectProxy* root_object_proxy_;
- scoped_ptr<TestService> test_service_;
+ std::unique_ptr<TestService> test_service_;
// Text message from "Test" signal.
std::string test_signal_string_;
// Text message from "Test" signal delivered to root.
diff --git a/dbus/end_to_end_sync_unittest.cc b/dbus/end_to_end_sync_unittest.cc
index 47dc9b1..4eb9cd1 100644
--- a/dbus/end_to_end_sync_unittest.cc
+++ b/dbus/end_to_end_sync_unittest.cc
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
@@ -47,7 +48,7 @@
}
protected:
- scoped_ptr<TestService> test_service_;
+ std::unique_ptr<TestService> test_service_;
scoped_refptr<Bus> client_bus_;
ObjectProxy* object_proxy_;
};
@@ -62,7 +63,7 @@
// Call the method.
const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT;
- scoped_ptr<Response> response(
+ std::unique_ptr<Response> response(
object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
ASSERT_TRUE(response.get());
@@ -83,7 +84,7 @@
// Call the method with timeout of 0ms.
const int timeout_ms = 0;
- scoped_ptr<Response> response(
+ std::unique_ptr<Response> response(
object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
// Should fail because of timeout.
ASSERT_FALSE(response.get());
@@ -93,7 +94,7 @@
MethodCall method_call("org.chromium.TestInterface", "Nonexistent");
const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT;
- scoped_ptr<Response> response(
+ std::unique_ptr<Response> response(
object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
ASSERT_FALSE(response.get());
}
@@ -102,7 +103,7 @@
MethodCall method_call("org.chromium.TestInterface", "BrokenMethod");
const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT;
- scoped_ptr<Response> response(
+ std::unique_ptr<Response> response(
object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
ASSERT_FALSE(response.get());
}
@@ -118,7 +119,7 @@
MethodCall method_call("org.chromium.TestInterface", "Echo");
const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT;
- scoped_ptr<Response> response(
+ std::unique_ptr<Response> response(
object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
ASSERT_FALSE(response.get());
}
@@ -134,7 +135,7 @@
MethodCall method_call("org.chromium.TestInterface", "Echo");
const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT;
- scoped_ptr<Response> response(
+ std::unique_ptr<Response> response(
object_proxy_->CallMethodAndBlock(&method_call, timeout_ms));
ASSERT_FALSE(response.get());
}
diff --git a/dbus/exported_object.cc b/dbus/exported_object.cc
index e4cd1a4..19d1715 100644
--- a/dbus/exported_object.cc
+++ b/dbus/exported_object.cc
@@ -195,7 +195,7 @@
// raw_message will be unrefed on exit of the function. Increment the
// reference so we can use it in MethodCall.
dbus_message_ref(raw_message);
- scoped_ptr<MethodCall> method_call(
+ std::unique_ptr<MethodCall> method_call(
MethodCall::FromRawMessage(raw_message));
const std::string interface = method_call->GetInterface();
const std::string member = method_call->GetMember();
@@ -241,7 +241,7 @@
}
void ExportedObject::RunMethod(MethodCallCallback method_call_callback,
- scoped_ptr<MethodCall> method_call,
+ std::unique_ptr<MethodCall> method_call,
base::TimeTicks start_time) {
bus_->AssertOnOriginThread();
MethodCall* method = method_call.get();
@@ -253,8 +253,8 @@
}
void ExportedObject::SendResponse(base::TimeTicks start_time,
- scoped_ptr<MethodCall> method_call,
- scoped_ptr<Response> response) {
+ std::unique_ptr<MethodCall> method_call,
+ std::unique_ptr<Response> response) {
DCHECK(method_call);
if (bus_->HasDBusThread()) {
bus_->GetDBusTaskRunner()->PostTask(
@@ -269,8 +269,8 @@
}
}
-void ExportedObject::OnMethodCompleted(scoped_ptr<MethodCall> method_call,
- scoped_ptr<Response> response,
+void ExportedObject::OnMethodCompleted(std::unique_ptr<MethodCall> method_call,
+ std::unique_ptr<Response> response,
base::TimeTicks start_time) {
bus_->AssertOnDBusThread();
@@ -286,11 +286,9 @@
if (!response) {
// Something bad happened in the method call.
- scoped_ptr<ErrorResponse> error_response(
- ErrorResponse::FromMethodCall(
- method_call.get(),
- DBUS_ERROR_FAILED,
- "error occurred in " + method_call->GetMember()));
+ std::unique_ptr<ErrorResponse> error_response(ErrorResponse::FromMethodCall(
+ method_call.get(), DBUS_ERROR_FAILED,
+ "error occurred in " + method_call->GetMember()));
bus_->Send(error_response->raw_message(), NULL);
return;
}
diff --git a/dbus/exported_object.h b/dbus/exported_object.h
index 8a98b4a..69a63a5 100644
--- a/dbus/exported_object.h
+++ b/dbus/exported_object.h
@@ -8,12 +8,12 @@
#include <dbus/dbus.h>
#include <map>
+#include <memory>
#include <string>
#include <utility>
#include "base/callback.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -42,7 +42,8 @@
// Called to send a response from an exported method. |response| is the
// response message. Callers should pass NULL in the event of an error that
// prevents the sending of a response.
- typedef base::Callback<void (scoped_ptr<Response> response)> ResponseSender;
+ typedef base::Callback<void(std::unique_ptr<Response> response)>
+ ResponseSender;
// Called when an exported method is called. |method_call| is the request
// message. |sender| is the callback that's used to send a response.
@@ -139,20 +140,20 @@
// Runs the method. Helper function for HandleMessage().
void RunMethod(MethodCallCallback method_call_callback,
- scoped_ptr<MethodCall> method_call,
+ std::unique_ptr<MethodCall> method_call,
base::TimeTicks start_time);
// Callback invoked by service provider to send a response to a method call.
// Can be called immediately from a MethodCallCallback to implement a
// synchronous service or called later to implement an asynchronous service.
void SendResponse(base::TimeTicks start_time,
- scoped_ptr<MethodCall> method_call,
- scoped_ptr<Response> response);
+ std::unique_ptr<MethodCall> method_call,
+ std::unique_ptr<Response> response);
// Called on completion of the method run from SendResponse().
// Takes ownership of |method_call| and |response|.
- void OnMethodCompleted(scoped_ptr<MethodCall> method_call,
- scoped_ptr<Response> response,
+ void OnMethodCompleted(std::unique_ptr<MethodCall> method_call,
+ std::unique_ptr<Response> response,
base::TimeTicks start_time);
// Called when the object is unregistered.
diff --git a/dbus/file_descriptor.h b/dbus/file_descriptor.h
index b4f95cb..8fcab2f 100644
--- a/dbus/file_descriptor.h
+++ b/dbus/file_descriptor.h
@@ -5,7 +5,8 @@
#ifndef DBUS_FILE_DESCRIPTOR_H_
#define DBUS_FILE_DESCRIPTOR_H_
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
#include "base/move.h"
#include "dbus/dbus_export.h"
@@ -84,7 +85,7 @@
};
using ScopedFileDescriptor =
- scoped_ptr<FileDescriptor, FileDescriptor::Deleter>;
+ std::unique_ptr<FileDescriptor, FileDescriptor::Deleter>;
} // namespace dbus
diff --git a/dbus/message.cc b/dbus/message.cc
index fe497ba..4a84756 100644
--- a/dbus/message.cc
+++ b/dbus/message.cc
@@ -398,23 +398,23 @@
Response::Response() : Message() {
}
-scoped_ptr<Response> Response::FromRawMessage(DBusMessage* raw_message) {
+std::unique_ptr<Response> Response::FromRawMessage(DBusMessage* raw_message) {
DCHECK_EQ(DBUS_MESSAGE_TYPE_METHOD_RETURN,
dbus_message_get_type(raw_message));
- scoped_ptr<Response> response(new Response);
+ std::unique_ptr<Response> response(new Response);
response->Init(raw_message);
return response;
}
-scoped_ptr<Response> Response::FromMethodCall(MethodCall* method_call) {
- scoped_ptr<Response> response(new Response);
+std::unique_ptr<Response> Response::FromMethodCall(MethodCall* method_call) {
+ std::unique_ptr<Response> response(new Response);
response->Init(dbus_message_new_method_return(method_call->raw_message()));
return response;
}
-scoped_ptr<Response> Response::CreateEmpty() {
- scoped_ptr<Response> response(new Response);
+std::unique_ptr<Response> Response::CreateEmpty() {
+ std::unique_ptr<Response> response(new Response);
response->Init(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN));
return response;
}
@@ -426,20 +426,20 @@
ErrorResponse::ErrorResponse() : Response() {
}
-scoped_ptr<ErrorResponse> ErrorResponse::FromRawMessage(
+std::unique_ptr<ErrorResponse> ErrorResponse::FromRawMessage(
DBusMessage* raw_message) {
DCHECK_EQ(DBUS_MESSAGE_TYPE_ERROR, dbus_message_get_type(raw_message));
- scoped_ptr<ErrorResponse> response(new ErrorResponse);
+ std::unique_ptr<ErrorResponse> response(new ErrorResponse);
response->Init(raw_message);
return response;
}
-scoped_ptr<ErrorResponse> ErrorResponse::FromMethodCall(
+std::unique_ptr<ErrorResponse> ErrorResponse::FromMethodCall(
MethodCall* method_call,
const std::string& error_name,
const std::string& error_message) {
- scoped_ptr<ErrorResponse> response(new ErrorResponse);
+ std::unique_ptr<ErrorResponse> response(new ErrorResponse);
response->Init(dbus_message_new_error(method_call->raw_message(),
error_name.c_str(),
error_message.c_str()));
diff --git a/dbus/message.h b/dbus/message.h
index b382032..0aa010c 100644
--- a/dbus/message.h
+++ b/dbus/message.h
@@ -8,11 +8,12 @@
#include <dbus/dbus.h>
#include <stddef.h>
#include <stdint.h>
+
+#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "dbus/dbus_export.h"
#include "dbus/file_descriptor.h"
#include "dbus/object_path.h"
@@ -204,16 +205,16 @@
public:
// Returns a newly created Response from the given raw message of the
// type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|.
- static scoped_ptr<Response> FromRawMessage(DBusMessage* raw_message);
+ static std::unique_ptr<Response> FromRawMessage(DBusMessage* raw_message);
// Returns a newly created Response from the given method call.
// Used for implementing exported methods. Does NOT take the ownership of
// |method_call|.
- static scoped_ptr<Response> FromMethodCall(MethodCall* method_call);
+ static std::unique_ptr<Response> FromMethodCall(MethodCall* method_call);
// Returns a newly created Response with an empty payload.
// Useful for testing.
- static scoped_ptr<Response> CreateEmpty();
+ static std::unique_ptr<Response> CreateEmpty();
protected:
// Creates a Response message. The internal raw message is NULL.
@@ -229,13 +230,14 @@
public:
// Returns a newly created Response from the given raw message of the
// type DBUS_MESSAGE_TYPE_METHOD_RETURN. Takes the ownership of |raw_message|.
- static scoped_ptr<ErrorResponse> FromRawMessage(DBusMessage* raw_message);
+ static std::unique_ptr<ErrorResponse> FromRawMessage(
+ DBusMessage* raw_message);
// Returns a newly created ErrorResponse from the given method call, the
// error name, and the error message. The error name looks like
// "org.freedesktop.DBus.Error.Failed". Used for returning an error to a
// failed method call. Does NOT take the ownership of |method_call|.
- static scoped_ptr<ErrorResponse> FromMethodCall(
+ static std::unique_ptr<ErrorResponse> FromMethodCall(
MethodCall* method_call,
const std::string& error_name,
const std::string& error_message);
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc
index 65d49f7..a58b36b 100644
--- a/dbus/message_unittest.cc
+++ b/dbus/message_unittest.cc
@@ -7,8 +7,9 @@
#include <stddef.h>
#include <stdint.h>
+#include <memory>
+
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
#include "dbus/object_path.h"
#include "dbus/test_proto.pb.h"
@@ -19,7 +20,7 @@
// Test that a byte can be properly written and read. We only have this
// test for byte, as repeating this for other basic types is too redundant.
TEST(MessageTest, AppendAndPopByte) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
writer.AppendByte(123); // The input is 123.
@@ -43,7 +44,7 @@
// Check all basic types can be properly written and read.
TEST(MessageTest, AppendAndPopBasicDataTypes) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
// Append 0, 1, 2, 3, 4, 5, 6, 7, 8, "string", "/object/path".
@@ -119,7 +120,7 @@
return;
}
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
// Append stdout.
@@ -158,7 +159,7 @@
// Check all variant types can be properly written and read.
TEST(MessageTest, AppendAndPopVariantDataTypes) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
// Append 0, 1, 2, 3, 4, 5, 6, 7, 8, "string", "/object/path".
@@ -228,7 +229,7 @@
}
TEST(MessageTest, ArrayOfBytes) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
std::vector<uint8_t> bytes;
bytes.push_back(1);
@@ -249,7 +250,7 @@
}
TEST(MessageTest, ArrayOfDoubles) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
std::vector<double> doubles;
doubles.push_back(0.2);
@@ -270,7 +271,7 @@
}
TEST(MessageTest, ArrayOfBytes_Empty) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
std::vector<uint8_t> bytes;
writer.AppendArrayOfBytes(bytes.data(), bytes.size());
@@ -286,7 +287,7 @@
}
TEST(MessageTest, ArrayOfStrings) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
std::vector<std::string> strings;
strings.push_back("fee");
@@ -308,7 +309,7 @@
}
TEST(MessageTest, ArrayOfObjectPaths) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
std::vector<ObjectPath> object_paths;
object_paths.push_back(ObjectPath("/object/path/1"));
@@ -328,7 +329,7 @@
}
TEST(MessageTest, ProtoBuf) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
TestProto send_message;
send_message.set_text("testing");
@@ -348,7 +349,7 @@
// test for array, as repeating this for other container types is too
// redundant.
TEST(MessageTest, OpenArrayAndPopArray) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
MessageWriter array_writer(NULL);
writer.OpenArray("s", &array_writer); // Open an array of strings.
@@ -378,7 +379,7 @@
// Create a complex message using array, struct, variant, dict entry, and
// make sure it can be read properly.
TEST(MessageTest, CreateComplexMessageAndReadIt) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
{
MessageWriter array_writer(NULL);
@@ -536,7 +537,8 @@
dbus_message_set_interface(raw_message, "com.example.Interface");
dbus_message_set_member(raw_message, "SomeMethod");
- scoped_ptr<MethodCall> method_call(MethodCall::FromRawMessage(raw_message));
+ std::unique_ptr<MethodCall> method_call(
+ MethodCall::FromRawMessage(raw_message));
EXPECT_EQ("com.example.Interface", method_call->GetInterface());
EXPECT_EQ("SomeMethod", method_call->GetMember());
}
@@ -566,13 +568,13 @@
dbus_message_set_interface(raw_message, "com.example.Interface");
dbus_message_set_member(raw_message, "SomeSignal");
- scoped_ptr<Signal> signal(Signal::FromRawMessage(raw_message));
+ std::unique_ptr<Signal> signal(Signal::FromRawMessage(raw_message));
EXPECT_EQ("com.example.Interface", signal->GetInterface());
EXPECT_EQ("SomeSignal", signal->GetMember());
}
TEST(MessageTest, Response) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
EXPECT_TRUE(response->raw_message());
EXPECT_EQ(Message::MESSAGE_METHOD_RETURN, response->GetMessageType());
EXPECT_EQ("MESSAGE_METHOD_RETURN", response->GetMessageTypeAsString());
@@ -583,8 +585,7 @@
MethodCall method_call("com.example.Interface", "SomeMethod");
method_call.SetSerial(kSerial);
- scoped_ptr<Response> response(
- Response::FromMethodCall(&method_call));
+ std::unique_ptr<Response> response(Response::FromMethodCall(&method_call));
EXPECT_EQ(Message::MESSAGE_METHOD_RETURN, response->GetMessageType());
EXPECT_EQ("MESSAGE_METHOD_RETURN", response->GetMessageTypeAsString());
// The serial should be copied to the reply serial.
@@ -598,10 +599,8 @@
MethodCall method_call("com.example.Interface", "SomeMethod");
method_call.SetSerial(kSerial);
- scoped_ptr<ErrorResponse> error_response(
- ErrorResponse::FromMethodCall(&method_call,
- DBUS_ERROR_FAILED,
- kErrorMessage));
+ std::unique_ptr<ErrorResponse> error_response(ErrorResponse::FromMethodCall(
+ &method_call, DBUS_ERROR_FAILED, kErrorMessage));
EXPECT_EQ(Message::MESSAGE_ERROR, error_response->GetMessageType());
EXPECT_EQ("MESSAGE_ERROR", error_response->GetMessageTypeAsString());
// The serial should be copied to the reply serial.
@@ -615,7 +614,7 @@
}
TEST(MessageTest, GetAndSetHeaders) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
EXPECT_EQ("", message->GetDestination());
EXPECT_EQ(ObjectPath(std::string()), message->GetPath());
@@ -646,7 +645,7 @@
}
TEST(MessageTest, SetInvalidHeaders) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
EXPECT_EQ("", message->GetDestination());
EXPECT_EQ(ObjectPath(std::string()), message->GetPath());
EXPECT_EQ("", message->GetInterface());
@@ -678,7 +677,7 @@
TEST(MessageTest, ToString_LongString) {
const std::string kLongString(1000, 'o');
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
writer.AppendString(kLongString);
diff --git a/dbus/mock_object_proxy.h b/dbus/mock_object_proxy.h
index 66f485a..f27f6f6 100644
--- a/dbus/mock_object_proxy.h
+++ b/dbus/mock_object_proxy.h
@@ -21,27 +21,28 @@
const std::string& service_name,
const ObjectPath& object_path);
- // GMock doesn't support the return type of scoped_ptr<> because scoped_ptr is
- // uncopyable. This is a workaround which defines |MockCallMethodAndBlock| as
- // a mock method and makes |CallMethodAndBlock| call the mocked method.
- // Use |MockCallMethodAndBlock| for setting/testing expectations.
+ // GMock doesn't support the return type of std::unique_ptr<> because
+ // std::unique_ptr is uncopyable. This is a workaround which defines
+ // |MockCallMethodAndBlock| as a mock method and makes
+ // |CallMethodAndBlock| call the mocked method. Use |MockCallMethodAndBlock|
+ // for setting/testing expectations.
MOCK_METHOD3(MockCallMethodAndBlockWithErrorDetails,
Response*(MethodCall* method_call,
int timeout_ms,
ScopedDBusError* error));
- scoped_ptr<Response> CallMethodAndBlockWithErrorDetails(
+ std::unique_ptr<Response> CallMethodAndBlockWithErrorDetails(
MethodCall* method_call,
int timeout_ms,
ScopedDBusError* error) override {
- return scoped_ptr<Response>(
+ return std::unique_ptr<Response>(
MockCallMethodAndBlockWithErrorDetails(method_call, timeout_ms, error));
}
MOCK_METHOD2(MockCallMethodAndBlock, Response*(MethodCall* method_call,
int timeout_ms));
- scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call,
- int timeout_ms) override {
- return scoped_ptr<Response>(MockCallMethodAndBlock(method_call,
- timeout_ms));
+ std::unique_ptr<Response> CallMethodAndBlock(MethodCall* method_call,
+ int timeout_ms) override {
+ return std::unique_ptr<Response>(
+ MockCallMethodAndBlock(method_call, timeout_ms));
}
MOCK_METHOD3(CallMethod, void(MethodCall* method_call,
int timeout_ms,
diff --git a/dbus/mock_unittest.cc b/dbus/mock_unittest.cc
index 6b2a521..ed78e2c 100644
--- a/dbus/mock_unittest.cc
+++ b/dbus/mock_unittest.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "dbus/message.h"
@@ -82,7 +83,7 @@
protected:
std::string response_string_;
base::MessageLoop message_loop_;
- scoped_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<base::RunLoop> run_loop_;
scoped_refptr<MockBus> mock_bus_;
scoped_refptr<MockObjectProxy> mock_proxy_;
@@ -96,7 +97,7 @@
MessageReader reader(method_call);
std::string text_message;
if (reader.PopString(&text_message)) {
- scoped_ptr<Response> response = Response::CreateEmpty();
+ std::unique_ptr<Response> response = Response::CreateEmpty();
MessageWriter writer(response.get());
writer.AppendString(text_message);
return response.release();
@@ -151,9 +152,8 @@
writer.AppendString(kHello);
// Call the method.
- scoped_ptr<Response> response(
- proxy->CallMethodAndBlock(&method_call,
- ObjectProxy::TIMEOUT_USE_DEFAULT));
+ std::unique_ptr<Response> response(proxy->CallMethodAndBlock(
+ &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT));
// Check the response.
ASSERT_TRUE(response.get());
@@ -175,9 +175,8 @@
ScopedDBusError error;
// Call the method.
- scoped_ptr<Response> response(
- proxy->CallMethodAndBlockWithErrorDetails(
- &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT, &error));
+ std::unique_ptr<Response> response(proxy->CallMethodAndBlockWithErrorDetails(
+ &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT, &error));
// Check the response.
ASSERT_FALSE(response.get());
diff --git a/dbus/object_manager.cc b/dbus/object_manager.cc
index 9215d84..56143c7 100644
--- a/dbus/object_manager.cc
+++ b/dbus/object_manager.cc
@@ -263,8 +263,7 @@
// raw_message will be unrefed on exit of the function. Increment the
// reference so we can use it in Signal.
dbus_message_ref(raw_message);
- scoped_ptr<Signal> signal(
- Signal::FromRawMessage(raw_message));
+ std::unique_ptr<Signal> signal(Signal::FromRawMessage(raw_message));
const std::string interface = signal->GetInterface();
const std::string member = signal->GetMember();
diff --git a/dbus/object_manager_unittest.cc b/dbus/object_manager_unittest.cc
index 443210c..ae03776 100644
--- a/dbus/object_manager_unittest.cc
+++ b/dbus/object_manager_unittest.cc
@@ -205,11 +205,11 @@
}
base::MessageLoop message_loop_;
- scoped_ptr<base::RunLoop> run_loop_;
- scoped_ptr<base::Thread> dbus_thread_;
+ std::unique_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<base::Thread> dbus_thread_;
scoped_refptr<Bus> bus_;
ObjectManager* object_manager_;
- scoped_ptr<TestService> test_service_;
+ std::unique_ptr<TestService> test_service_;
std::string last_name_value_;
bool timeout_expired_;
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc
index 6c758b9..5d9d8e8 100644
--- a/dbus/object_proxy.cc
+++ b/dbus/object_proxy.cc
@@ -69,14 +69,16 @@
// Originally we tried to make |method_call| a const reference, but we
// gave up as dbus_connection_send_with_reply_and_block() takes a
// non-const pointer of DBusMessage as the second parameter.
-scoped_ptr<Response> ObjectProxy::CallMethodAndBlockWithErrorDetails(
- MethodCall* method_call, int timeout_ms, ScopedDBusError* error) {
+std::unique_ptr<Response> ObjectProxy::CallMethodAndBlockWithErrorDetails(
+ MethodCall* method_call,
+ int timeout_ms,
+ ScopedDBusError* error) {
bus_->AssertOnDBusThread();
if (!bus_->Connect() ||
!method_call->SetDestination(service_name_) ||
!method_call->SetPath(object_path_))
- return scoped_ptr<Response>();
+ return std::unique_ptr<Response>();
DBusMessage* request_message = method_call->raw_message();
@@ -97,7 +99,7 @@
method_call->GetMember(),
error->is_set() ? error->name() : "unknown error type",
error->is_set() ? error->message() : "");
- return scoped_ptr<Response>();
+ return std::unique_ptr<Response>();
}
// Record time spent for the method call. Don't include failures.
UMA_HISTOGRAM_TIMES("DBus.SyncMethodCallTime",
@@ -106,8 +108,9 @@
return Response::FromRawMessage(response_message);
}
-scoped_ptr<Response> ObjectProxy::CallMethodAndBlock(MethodCall* method_call,
- int timeout_ms) {
+std::unique_ptr<Response> ObjectProxy::CallMethodAndBlock(
+ MethodCall* method_call,
+ int timeout_ms) {
ScopedDBusError error;
return CallMethodAndBlockWithErrorDetails(method_call, timeout_ms, &error);
}
@@ -325,7 +328,7 @@
} else if (dbus_message_get_type(response_message) ==
DBUS_MESSAGE_TYPE_ERROR) {
// This will take |response_message| and release (unref) it.
- scoped_ptr<ErrorResponse> error_response(
+ std::unique_ptr<ErrorResponse> error_response(
ErrorResponse::FromRawMessage(response_message));
error_callback.Run(error_response.get());
// Delete the message on the D-Bus thread. See below for why.
@@ -335,7 +338,8 @@
error_response.release()));
} else {
// This will take |response_message| and release (unref) it.
- scoped_ptr<Response> response(Response::FromRawMessage(response_message));
+ std::unique_ptr<Response> response(
+ Response::FromRawMessage(response_message));
// The response is successfully received.
response_callback.Run(response.get());
// The message should be deleted on the D-Bus thread for a complicated
@@ -466,8 +470,7 @@
// raw_message will be unrefed on exit of the function. Increment the
// reference so we can use it in Signal.
dbus_message_ref(raw_message);
- scoped_ptr<Signal> signal(
- Signal::FromRawMessage(raw_message));
+ std::unique_ptr<Signal> signal(Signal::FromRawMessage(raw_message));
// Verify the signal comes from the object we're proxying for, this is
// our last chance to return DBUS_HANDLER_RESULT_NOT_YET_HANDLED and
@@ -659,7 +662,7 @@
}
DBusHandlerResult ObjectProxy::HandleNameOwnerChanged(
- scoped_ptr<Signal> signal) {
+ std::unique_ptr<Signal> signal) {
DCHECK(signal);
bus_->AssertOnDBusThread();
diff --git a/dbus/object_proxy.h b/dbus/object_proxy.h
index 839d5f7..033e886 100644
--- a/dbus/object_proxy.h
+++ b/dbus/object_proxy.h
@@ -8,6 +8,7 @@
#include <dbus/dbus.h>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string_piece.h"
#include "base/time/time.h"
#include "dbus/dbus_export.h"
@@ -98,7 +98,7 @@
// in the |error| object.
//
// BLOCKING CALL.
- virtual scoped_ptr<Response> CallMethodAndBlockWithErrorDetails(
+ virtual std::unique_ptr<Response> CallMethodAndBlockWithErrorDetails(
MethodCall* method_call,
int timeout_ms,
ScopedDBusError* error);
@@ -107,8 +107,8 @@
// is returned. Returns NULL on error.
//
// BLOCKING CALL.
- virtual scoped_ptr<Response> CallMethodAndBlock(MethodCall* method_call,
- int timeout_ms);
+ virtual std::unique_ptr<Response> CallMethodAndBlock(MethodCall* method_call,
+ int timeout_ms);
// Requests to call the method of the remote object.
//
@@ -290,7 +290,8 @@
void UpdateNameOwnerAndBlock();
// Handles NameOwnerChanged signal from D-Bus's special message bus.
- DBusHandlerResult HandleNameOwnerChanged(scoped_ptr<dbus::Signal> signal);
+ DBusHandlerResult HandleNameOwnerChanged(
+ std::unique_ptr<dbus::Signal> signal);
// Runs |name_owner_changed_callback_|.
void RunNameOwnerChangedCallback(const std::string& old_owner,
diff --git a/dbus/object_proxy_unittest.cc b/dbus/object_proxy_unittest.cc
index 05c1294..cc79f84 100644
--- a/dbus/object_proxy_unittest.cc
+++ b/dbus/object_proxy_unittest.cc
@@ -29,7 +29,7 @@
};
// Used as a WaitForServiceToBeAvailableCallback.
-void OnServiceIsAvailable(scoped_ptr<base::RunLoop>* run_loop,
+void OnServiceIsAvailable(std::unique_ptr<base::RunLoop>* run_loop,
bool service_is_available) {
EXPECT_TRUE(service_is_available);
ASSERT_TRUE(*run_loop);
@@ -37,7 +37,7 @@
}
TEST_F(ObjectProxyTest, WaitForServiceToBeAvailable) {
- scoped_ptr<base::RunLoop> run_loop;
+ std::unique_ptr<base::RunLoop> run_loop;
TestService::Options options;
TestService test_service(options);
diff --git a/dbus/property.cc b/dbus/property.cc
index 66af866..faca4a0 100644
--- a/dbus/property.cc
+++ b/dbus/property.cc
@@ -141,9 +141,8 @@
writer.AppendString(property->name());
DCHECK(object_proxy_);
- scoped_ptr<dbus::Response> response(
- object_proxy_->CallMethodAndBlock(&method_call,
- ObjectProxy::TIMEOUT_USE_DEFAULT));
+ std::unique_ptr<dbus::Response> response(object_proxy_->CallMethodAndBlock(
+ &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT));
if (!response.get()) {
LOG(WARNING) << property->name() << ": GetAndBlock: failed.";
@@ -212,9 +211,8 @@
property->AppendSetValueToWriter(&writer);
DCHECK(object_proxy_);
- scoped_ptr<dbus::Response> response(
- object_proxy_->CallMethodAndBlock(&method_call,
- ObjectProxy::TIMEOUT_USE_DEFAULT));
+ std::unique_ptr<dbus::Response> response(object_proxy_->CallMethodAndBlock(
+ &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT));
if (response.get())
return true;
return false;
diff --git a/dbus/property_unittest.cc b/dbus/property_unittest.cc
index f159284..5922554 100644
--- a/dbus/property_unittest.cc
+++ b/dbus/property_unittest.cc
@@ -158,12 +158,12 @@
}
base::MessageLoop message_loop_;
- scoped_ptr<base::RunLoop> run_loop_;
- scoped_ptr<base::Thread> dbus_thread_;
+ std::unique_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<base::Thread> dbus_thread_;
scoped_refptr<Bus> bus_;
ObjectProxy* object_proxy_;
- scoped_ptr<Properties> properties_;
- scoped_ptr<TestService> test_service_;
+ std::unique_ptr<Properties> properties_;
+ std::unique_ptr<TestService> test_service_;
// Properties updated.
std::vector<std::string> updated_properties_;
// Last callback received.
@@ -328,7 +328,7 @@
}
TEST(PropertyTestStatic, ReadWriteStringMap) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
MessageWriter variant_writer(NULL);
MessageWriter variant_array_writer(NULL);
@@ -362,7 +362,7 @@
test_map["Map"] = "Test";
test_map["Random"] = "Text";
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
Property<std::map<std::string, std::string>> string_map;
@@ -375,7 +375,7 @@
}
TEST(PropertyTestStatic, ReadWriteNetAddressArray) {
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
MessageWriter variant_writer(NULL);
MessageWriter variant_array_writer(NULL);
@@ -419,7 +419,7 @@
test_list.push_back(make_pair(bytes, 16));
}
- scoped_ptr<Response> message(Response::CreateEmpty());
+ std::unique_ptr<Response> message(Response::CreateEmpty());
MessageWriter writer(message.get());
Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>> ip_list;
diff --git a/dbus/signal_sender_verification_unittest.cc b/dbus/signal_sender_verification_unittest.cc
index 785948a..3b2cf6f 100644
--- a/dbus/signal_sender_verification_unittest.cc
+++ b/dbus/signal_sender_verification_unittest.cc
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_samples.h"
@@ -168,12 +169,12 @@
}
base::MessageLoop message_loop_;
- scoped_ptr<base::RunLoop> run_loop_;
- scoped_ptr<base::Thread> dbus_thread_;
+ std::unique_ptr<base::RunLoop> run_loop_;
+ std::unique_ptr<base::Thread> dbus_thread_;
scoped_refptr<Bus> bus_;
ObjectProxy* object_proxy_;
- scoped_ptr<TestService> test_service_;
- scoped_ptr<TestService> test_service2_;
+ std::unique_ptr<TestService> test_service_;
+ std::unique_ptr<TestService> test_service2_;
// Text message from "Test" signal.
std::string test_signal_string_;
@@ -201,7 +202,7 @@
UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 0);
base::HistogramBase* reject_signal_histogram =
base::StatisticsRecorder::FindHistogram("DBus.RejectedSignalCount");
- scoped_ptr<base::HistogramSamples> samples1(
+ std::unique_ptr<base::HistogramSamples> samples1(
reject_signal_histogram->SnapshotSamples());
const char kNewMessage[] = "hello, new world";
@@ -211,7 +212,7 @@
// Sleep to have message delivered to the client via the D-Bus service.
base::PlatformThread::Sleep(TestTimeouts::action_timeout());
- scoped_ptr<base::HistogramSamples> samples2(
+ std::unique_ptr<base::HistogramSamples> samples2(
reject_signal_histogram->SnapshotSamples());
ASSERT_EQ("", test_signal_string_);
diff --git a/dbus/values_util.cc b/dbus/values_util.cc
index e932312..ed435a1 100644
--- a/dbus/values_util.cc
+++ b/dbus/values_util.cc
@@ -4,9 +4,10 @@
#include "dbus/values_util.h"
+#include <memory>
+
#include "base/json/json_writer.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "dbus/message.h"
@@ -47,7 +48,7 @@
return false;
} else {
// If the type of keys is not STRING, convert it to string.
- scoped_ptr<base::Value> key(PopDataAsValue(&entry_reader));
+ std::unique_ptr<base::Value> key(PopDataAsValue(&entry_reader));
if (!key)
return false;
// Use JSONWriter to convert an arbitrary value to a string.
@@ -176,12 +177,12 @@
// If the type of the array's element is DICT_ENTRY, create a
// DictionaryValue, otherwise create a ListValue.
if (sub_reader.GetDataType() == Message::DICT_ENTRY) {
- scoped_ptr<base::DictionaryValue> dictionary_value(
+ std::unique_ptr<base::DictionaryValue> dictionary_value(
new base::DictionaryValue);
if (PopDictionaryEntries(&sub_reader, dictionary_value.get()))
result = dictionary_value.release();
} else {
- scoped_ptr<base::ListValue> list_value(new base::ListValue);
+ std::unique_ptr<base::ListValue> list_value(new base::ListValue);
if (PopListElements(&sub_reader, list_value.get()))
result = list_value.release();
}
@@ -191,7 +192,7 @@
case Message::STRUCT: {
MessageReader sub_reader(NULL);
if (reader->PopStruct(&sub_reader)) {
- scoped_ptr<base::ListValue> list_value(new base::ListValue);
+ std::unique_ptr<base::ListValue> list_value(new base::ListValue);
if (PopListElements(&sub_reader, list_value.get()))
result = list_value.release();
}
diff --git a/dbus/values_util_unittest.cc b/dbus/values_util_unittest.cc
index b2f1404..6903d51 100644
--- a/dbus/values_util_unittest.cc
+++ b/dbus/values_util_unittest.cc
@@ -8,11 +8,11 @@
#include <stdint.h>
#include <cmath>
+#include <memory>
#include <vector>
#include "base/json/json_writer.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/values.h"
#include "dbus/message.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,7 +20,7 @@
namespace dbus {
TEST(ValuesUtilTest, PopBasicTypes) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append basic type values.
MessageWriter writer(response.get());
const uint8_t kByteValue = 42;
@@ -49,8 +49,8 @@
writer.AppendObjectPath(kObjectPathValue);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
- scoped_ptr<base::Value> expected_value;
+ std::unique_ptr<base::Value> value;
+ std::unique_ptr<base::Value> expected_value;
// Pop a byte.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
@@ -117,7 +117,7 @@
}
TEST(ValuesUtilTest, PopVariant) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append variant values.
MessageWriter writer(response.get());
const bool kBoolValue = true;
@@ -130,8 +130,8 @@
writer.AppendVariantOfString(kStringValue);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
- scoped_ptr<base::Value> expected_value;
+ std::unique_ptr<base::Value> value;
+ std::unique_ptr<base::Value> expected_value;
// Pop a bool.
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
@@ -157,7 +157,7 @@
// Pop extremely large integers which cannot be precisely represented in
// double.
TEST(ValuesUtilTest, PopExtremelyLargeIntegers) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append large integers.
MessageWriter writer(response.get());
const int64_t kInt64Value = -123456789012345689LL;
@@ -166,8 +166,8 @@
writer.AppendUint64(kUint64Value);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
- scoped_ptr<base::Value> expected_value;
+ std::unique_ptr<base::Value> value;
+ std::unique_ptr<base::Value> expected_value;
double double_value = 0;
// Pop an int64_t.
value.reset(PopDataAsValue(&reader));
@@ -188,7 +188,7 @@
}
TEST(ValuesUtilTest, PopIntArray) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append an int32_t array.
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
@@ -202,19 +202,19 @@
writer.CloseContainer(&sub_writer);
// Create the expected value.
- scoped_ptr<base::ListValue> list_value(new base::ListValue);
+ 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]));
// Pop an int32_t array.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value(PopDataAsValue(&reader));
+ std::unique_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(list_value.get()));
}
TEST(ValuesUtilTest, PopStringArray) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append a string array.
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
@@ -225,19 +225,19 @@
writer.AppendArrayOfStrings(data);
// Create the expected value.
- scoped_ptr<base::ListValue> list_value(new base::ListValue);
+ 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]));
// Pop a string array.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value(PopDataAsValue(&reader));
+ std::unique_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(list_value.get()));
}
TEST(ValuesUtilTest, PopStruct) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append a struct.
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
@@ -261,13 +261,13 @@
// Pop a struct.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value(PopDataAsValue(&reader));
+ std::unique_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&list_value));
}
TEST(ValuesUtilTest, PopStringToVariantDictionary) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append a dictionary.
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
@@ -308,13 +308,13 @@
// Pop a dictinoary.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value(PopDataAsValue(&reader));
+ std::unique_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&dictionary_value));
}
TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) {
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
// Append a dictionary.
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
@@ -351,7 +351,7 @@
// Pop a dictinoary.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value(PopDataAsValue(&reader));
+ std::unique_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&dictionary_value));
}
@@ -365,7 +365,7 @@
keys[i] = std::sqrt(values[i]);
// Append a dictionary.
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
MessageWriter sub_writer(NULL);
writer.OpenArray("{di}", &sub_writer);
@@ -388,7 +388,7 @@
// Pop a dictionary.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value(PopDataAsValue(&reader));
+ std::unique_ptr<base::Value> value(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&dictionary_value));
}
@@ -399,7 +399,7 @@
const base::FundamentalValue kDoubleValue(4.2);
const base::StringValue kStringValue("string");
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendBasicTypeValueData(&writer, kBoolValue);
AppendBasicTypeValueData(&writer, kIntegerValue);
@@ -407,7 +407,7 @@
AppendBasicTypeValueData(&writer, kStringValue);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
@@ -428,7 +428,7 @@
const base::FundamentalValue kDoubleValue(4.2);
const base::StringValue kStringValue("string");
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendBasicTypeValueDataAsVariant(&writer, kBoolValue);
AppendBasicTypeValueDataAsVariant(&writer, kIntegerValue);
@@ -436,7 +436,7 @@
AppendBasicTypeValueDataAsVariant(&writer, kStringValue);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
@@ -457,7 +457,7 @@
const base::FundamentalValue kDoubleValue(4.2);
const base::StringValue kStringValue("string");
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendValueData(&writer, kBoolValue);
AppendValueData(&writer, kIntegerValue);
@@ -465,7 +465,7 @@
AppendValueData(&writer, kStringValue);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
@@ -486,7 +486,7 @@
const base::FundamentalValue kDoubleValue(4.2);
const base::StringValue kStringValue("string");
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendValueDataAsVariant(&writer, kBoolValue);
AppendValueDataAsVariant(&writer, kIntegerValue);
@@ -494,7 +494,7 @@
AppendValueDataAsVariant(&writer, kStringValue);
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&kBoolValue));
@@ -539,7 +539,7 @@
test_dictionary.Set(kKey5, list_value); // takes ownership
test_dictionary.Set(kKey6, dictionary_value); // takes ownership
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendValueData(&writer, test_dictionary);
base::FundamentalValue int_value(kInt32Value);
@@ -547,7 +547,7 @@
// Read the data.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_dictionary));
@@ -586,7 +586,7 @@
test_dictionary.Set(kKey5, list_value); // takes ownership
test_dictionary.Set(kKey6, dictionary_value); // takes ownership
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendValueDataAsVariant(&writer, test_dictionary);
base::FundamentalValue int_value(kInt32Value);
@@ -594,7 +594,7 @@
// Read the data.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_dictionary));
@@ -629,7 +629,7 @@
test_list.Append(list_value); // takes ownership
test_list.Append(dictionary_value); // takes ownership
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendValueData(&writer, test_list);
base::FundamentalValue int_value(kInt32Value);
@@ -637,7 +637,7 @@
// Read the data.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_list));
@@ -672,7 +672,7 @@
test_list.Append(list_value); // takes ownership
test_list.Append(dictionary_value); // takes ownership
- scoped_ptr<Response> response(Response::CreateEmpty());
+ std::unique_ptr<Response> response(Response::CreateEmpty());
MessageWriter writer(response.get());
AppendValueDataAsVariant(&writer, test_list);
base::FundamentalValue int_value(kInt32Value);
@@ -680,7 +680,7 @@
// Read the data.
MessageReader reader(response.get());
- scoped_ptr<base::Value> value;
+ std::unique_ptr<base::Value> value;
value.reset(PopDataAsValue(&reader));
ASSERT_TRUE(value.get() != NULL);
EXPECT_TRUE(value->Equals(&test_list));