diff --git a/dbus/bus.cc b/dbus/bus.cc index 554ccb829d1a0e..1827928b9e0430 100644 --- a/dbus/bus.cc +++ b/dbus/bus.cc @@ -891,7 +891,8 @@ std::string Bus::GetServiceOwnerAndBlock(const std::string& service_name, return ""; } - scoped_ptr response(Response::FromRawMessage(response_message)); + std::unique_ptr response( + Response::FromRawMessage(response_message)); MessageReader reader(response.get()); std::string service_owner; @@ -1114,7 +1115,7 @@ void Bus::OnServiceOwnerChanged(DBusMessage* message) { // |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::FromRawMessage(message)); + std::unique_ptr 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 e5e0b1c6a99569..7d3915909b9fb4 100644 --- a/dbus/bus.h +++ b/dbus/bus.h @@ -88,7 +88,7 @@ class ObjectProxy; // bus.GetObjectProxy(service_name, object_path); // // dbus::MethodCall method_call(interface_name, method_name); -// scoped_ptr response( +// std::unique_ptr 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 250717ecee11ee..84bbb783f390a7 100644 --- a/dbus/bus_unittest.cc +++ b/dbus/bus_unittest.cc @@ -48,7 +48,7 @@ class RunLoopWithExpectedCount { } private: - scoped_ptr run_loop_; + std::unique_ptr run_loop_; int expected_quit_calls_; int actual_quit_calls_; diff --git a/dbus/dbus_statistics.cc b/dbus/dbus_statistics.cc index e6eb5a2f5b555b..e1e0973d5c78ea 100644 --- a/dbus/dbus_statistics.cc +++ b/dbus/dbus_statistics.cc @@ -4,11 +4,11 @@ #include "dbus/dbus_statistics.h" +#include #include #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 @@ class DBusStatistics { const std::string& method, bool add_stat) { DCHECK_EQ(origin_thread_id_, base::PlatformThread::CurrentId()); - scoped_ptr stat(new Stat(service, interface, method)); + std::unique_ptr 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 8f628649d6fc77..b02b043941882a 100644 --- a/dbus/end_to_end_async_unittest.cc +++ b/dbus/end_to_end_async_unittest.cc @@ -5,12 +5,12 @@ #include #include +#include #include #include #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 @@ class EndToEndAsyncTest : public testing::Test { } base::MessageLoop message_loop_; - scoped_ptr run_loop_; + std::unique_ptr run_loop_; std::vector response_strings_; std::vector error_names_; - scoped_ptr dbus_thread_; + std::unique_ptr dbus_thread_; scoped_refptr bus_; ObjectProxy* object_proxy_; ObjectProxy* root_object_proxy_; - scoped_ptr test_service_; + std::unique_ptr 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 47dc9b1207fefc..4eb9cd1950c8f8 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 + #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 @@ class EndToEndSyncTest : public testing::Test { } protected: - scoped_ptr test_service_; + std::unique_ptr test_service_; scoped_refptr client_bus_; ObjectProxy* object_proxy_; }; @@ -62,7 +63,7 @@ TEST_F(EndToEndSyncTest, Echo) { // Call the method. const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; - scoped_ptr response( + std::unique_ptr response( object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); ASSERT_TRUE(response.get()); @@ -83,7 +84,7 @@ TEST_F(EndToEndSyncTest, Timeout) { // Call the method with timeout of 0ms. const int timeout_ms = 0; - scoped_ptr response( + std::unique_ptr response( object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); // Should fail because of timeout. ASSERT_FALSE(response.get()); @@ -93,7 +94,7 @@ TEST_F(EndToEndSyncTest, NonexistentMethod) { MethodCall method_call("org.chromium.TestInterface", "Nonexistent"); const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; - scoped_ptr response( + std::unique_ptr response( object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); ASSERT_FALSE(response.get()); } @@ -102,7 +103,7 @@ TEST_F(EndToEndSyncTest, BrokenMethod) { MethodCall method_call("org.chromium.TestInterface", "BrokenMethod"); const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; - scoped_ptr response( + std::unique_ptr response( object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); ASSERT_FALSE(response.get()); } @@ -118,7 +119,7 @@ TEST_F(EndToEndSyncTest, InvalidObjectPath) { MethodCall method_call("org.chromium.TestInterface", "Echo"); const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; - scoped_ptr response( + std::unique_ptr response( object_proxy_->CallMethodAndBlock(&method_call, timeout_ms)); ASSERT_FALSE(response.get()); } @@ -134,7 +135,7 @@ TEST_F(EndToEndSyncTest, InvalidServiceName) { MethodCall method_call("org.chromium.TestInterface", "Echo"); const int timeout_ms = ObjectProxy::TIMEOUT_USE_DEFAULT; - scoped_ptr response( + std::unique_ptr 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 e4cd1a4219f8dc..19d17150ea4189 100644 --- a/dbus/exported_object.cc +++ b/dbus/exported_object.cc @@ -195,7 +195,7 @@ DBusHandlerResult ExportedObject::HandleMessage( // 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 method_call( + std::unique_ptr method_call( MethodCall::FromRawMessage(raw_message)); const std::string interface = method_call->GetInterface(); const std::string member = method_call->GetMember(); @@ -241,7 +241,7 @@ DBusHandlerResult ExportedObject::HandleMessage( } void ExportedObject::RunMethod(MethodCallCallback method_call_callback, - scoped_ptr method_call, + std::unique_ptr method_call, base::TimeTicks start_time) { bus_->AssertOnOriginThread(); MethodCall* method = method_call.get(); @@ -253,8 +253,8 @@ void ExportedObject::RunMethod(MethodCallCallback method_call_callback, } void ExportedObject::SendResponse(base::TimeTicks start_time, - scoped_ptr method_call, - scoped_ptr response) { + std::unique_ptr method_call, + std::unique_ptr response) { DCHECK(method_call); if (bus_->HasDBusThread()) { bus_->GetDBusTaskRunner()->PostTask( @@ -269,8 +269,8 @@ void ExportedObject::SendResponse(base::TimeTicks start_time, } } -void ExportedObject::OnMethodCompleted(scoped_ptr method_call, - scoped_ptr response, +void ExportedObject::OnMethodCompleted(std::unique_ptr method_call, + std::unique_ptr response, base::TimeTicks start_time) { bus_->AssertOnDBusThread(); @@ -286,11 +286,9 @@ void ExportedObject::OnMethodCompleted(scoped_ptr method_call, if (!response) { // Something bad happened in the method call. - scoped_ptr error_response( - ErrorResponse::FromMethodCall( - method_call.get(), - DBUS_ERROR_FAILED, - "error occurred in " + method_call->GetMember())); + std::unique_ptr 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 8a98b4ab74c984..69a63a5e075e5a 100644 --- a/dbus/exported_object.h +++ b/dbus/exported_object.h @@ -8,12 +8,12 @@ #include #include +#include #include #include #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 @@ class CHROME_DBUS_EXPORT ExportedObject // 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 response)> ResponseSender; + typedef base::Callback 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 @@ class CHROME_DBUS_EXPORT ExportedObject // Runs the method. Helper function for HandleMessage(). void RunMethod(MethodCallCallback method_call_callback, - scoped_ptr method_call, + std::unique_ptr 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 method_call, - scoped_ptr response); + std::unique_ptr method_call, + std::unique_ptr response); // Called on completion of the method run from SendResponse(). // Takes ownership of |method_call| and |response|. - void OnMethodCompleted(scoped_ptr method_call, - scoped_ptr response, + void OnMethodCompleted(std::unique_ptr method_call, + std::unique_ptr response, base::TimeTicks start_time); // Called when the object is unregistered. diff --git a/dbus/file_descriptor.h b/dbus/file_descriptor.h index b4f95cb593ce5f..8fcab2f440f4b0 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 + #include "base/move.h" #include "dbus/dbus_export.h" @@ -84,7 +85,7 @@ class CHROME_DBUS_EXPORT FileDescriptor { }; using ScopedFileDescriptor = - scoped_ptr; + std::unique_ptr; } // namespace dbus diff --git a/dbus/message.cc b/dbus/message.cc index fe497ba9a6e06e..4a84756c41fcb6 100644 --- a/dbus/message.cc +++ b/dbus/message.cc @@ -398,23 +398,23 @@ Signal* Signal::FromRawMessage(DBusMessage* raw_message) { Response::Response() : Message() { } -scoped_ptr Response::FromRawMessage(DBusMessage* raw_message) { +std::unique_ptr Response::FromRawMessage(DBusMessage* raw_message) { DCHECK_EQ(DBUS_MESSAGE_TYPE_METHOD_RETURN, dbus_message_get_type(raw_message)); - scoped_ptr response(new Response); + std::unique_ptr response(new Response); response->Init(raw_message); return response; } -scoped_ptr Response::FromMethodCall(MethodCall* method_call) { - scoped_ptr response(new Response); +std::unique_ptr Response::FromMethodCall(MethodCall* method_call) { + std::unique_ptr response(new Response); response->Init(dbus_message_new_method_return(method_call->raw_message())); return response; } -scoped_ptr Response::CreateEmpty() { - scoped_ptr response(new Response); +std::unique_ptr Response::CreateEmpty() { + std::unique_ptr response(new Response); response->Init(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN)); return response; } @@ -426,20 +426,20 @@ scoped_ptr Response::CreateEmpty() { ErrorResponse::ErrorResponse() : Response() { } -scoped_ptr ErrorResponse::FromRawMessage( +std::unique_ptr ErrorResponse::FromRawMessage( DBusMessage* raw_message) { DCHECK_EQ(DBUS_MESSAGE_TYPE_ERROR, dbus_message_get_type(raw_message)); - scoped_ptr response(new ErrorResponse); + std::unique_ptr response(new ErrorResponse); response->Init(raw_message); return response; } -scoped_ptr ErrorResponse::FromMethodCall( +std::unique_ptr ErrorResponse::FromMethodCall( MethodCall* method_call, const std::string& error_name, const std::string& error_message) { - scoped_ptr response(new ErrorResponse); + std::unique_ptr 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 b382032c805d32..0aa010ccde0b74 100644 --- a/dbus/message.h +++ b/dbus/message.h @@ -8,11 +8,12 @@ #include #include #include + +#include #include #include #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 @@ class CHROME_DBUS_EXPORT Response : public Message { 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 FromRawMessage(DBusMessage* raw_message); + static std::unique_ptr 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 FromMethodCall(MethodCall* method_call); + static std::unique_ptr FromMethodCall(MethodCall* method_call); // Returns a newly created Response with an empty payload. // Useful for testing. - static scoped_ptr CreateEmpty(); + static std::unique_ptr CreateEmpty(); protected: // Creates a Response message. The internal raw message is NULL. @@ -229,13 +230,14 @@ class CHROME_DBUS_EXPORT ErrorResponse: public Response { 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 FromRawMessage(DBusMessage* raw_message); + static std::unique_ptr 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 FromMethodCall( + static std::unique_ptr 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 65d49f77010b11..a58b36b2dc08eb 100644 --- a/dbus/message_unittest.cc +++ b/dbus/message_unittest.cc @@ -7,8 +7,9 @@ #include #include +#include + #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 @@ namespace dbus { // 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 message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); writer.AppendByte(123); // The input is 123. @@ -43,7 +44,7 @@ TEST(MessageTest, AppendAndPopByte) { // Check all basic types can be properly written and read. TEST(MessageTest, AppendAndPopBasicDataTypes) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); // Append 0, 1, 2, 3, 4, 5, 6, 7, 8, "string", "/object/path". @@ -119,7 +120,7 @@ TEST(MessageTest, AppendAndPopFileDescriptor) { return; } - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); // Append stdout. @@ -158,7 +159,7 @@ TEST(MessageTest, AppendAndPopFileDescriptor) { // Check all variant types can be properly written and read. TEST(MessageTest, AppendAndPopVariantDataTypes) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr 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, AppendAndPopVariantDataTypes) { } TEST(MessageTest, ArrayOfBytes) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); std::vector bytes; bytes.push_back(1); @@ -249,7 +250,7 @@ TEST(MessageTest, ArrayOfBytes) { } TEST(MessageTest, ArrayOfDoubles) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); std::vector doubles; doubles.push_back(0.2); @@ -270,7 +271,7 @@ TEST(MessageTest, ArrayOfDoubles) { } TEST(MessageTest, ArrayOfBytes_Empty) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); std::vector bytes; writer.AppendArrayOfBytes(bytes.data(), bytes.size()); @@ -286,7 +287,7 @@ TEST(MessageTest, ArrayOfBytes_Empty) { } TEST(MessageTest, ArrayOfStrings) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); std::vector strings; strings.push_back("fee"); @@ -308,7 +309,7 @@ TEST(MessageTest, ArrayOfStrings) { } TEST(MessageTest, ArrayOfObjectPaths) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); std::vector object_paths; object_paths.push_back(ObjectPath("/object/path/1")); @@ -328,7 +329,7 @@ TEST(MessageTest, ArrayOfObjectPaths) { } TEST(MessageTest, ProtoBuf) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); TestProto send_message; send_message.set_text("testing"); @@ -348,7 +349,7 @@ TEST(MessageTest, ProtoBuf) { // test for array, as repeating this for other container types is too // redundant. TEST(MessageTest, OpenArrayAndPopArray) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr 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 @@ TEST(MessageTest, OpenArrayAndPopArray) { // Create a complex message using array, struct, variant, dict entry, and // make sure it can be read properly. TEST(MessageTest, CreateComplexMessageAndReadIt) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); { MessageWriter array_writer(NULL); @@ -536,7 +537,8 @@ TEST(MessageTest, MethodCall_FromRawMessage) { dbus_message_set_interface(raw_message, "com.example.Interface"); dbus_message_set_member(raw_message, "SomeMethod"); - scoped_ptr method_call(MethodCall::FromRawMessage(raw_message)); + std::unique_ptr method_call( + MethodCall::FromRawMessage(raw_message)); EXPECT_EQ("com.example.Interface", method_call->GetInterface()); EXPECT_EQ("SomeMethod", method_call->GetMember()); } @@ -566,13 +568,13 @@ TEST(MessageTest, Signal_FromRawMessage) { dbus_message_set_interface(raw_message, "com.example.Interface"); dbus_message_set_member(raw_message, "SomeSignal"); - scoped_ptr signal(Signal::FromRawMessage(raw_message)); + std::unique_ptr signal(Signal::FromRawMessage(raw_message)); EXPECT_EQ("com.example.Interface", signal->GetInterface()); EXPECT_EQ("SomeSignal", signal->GetMember()); } TEST(MessageTest, Response) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr 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 @@ TEST(MessageTest, Response_FromMethodCall) { MethodCall method_call("com.example.Interface", "SomeMethod"); method_call.SetSerial(kSerial); - scoped_ptr response( - Response::FromMethodCall(&method_call)); + std::unique_ptr 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 @@ const char kErrorMessage[] = "error message"; MethodCall method_call("com.example.Interface", "SomeMethod"); method_call.SetSerial(kSerial); - scoped_ptr error_response( - ErrorResponse::FromMethodCall(&method_call, - DBUS_ERROR_FAILED, - kErrorMessage)); + std::unique_ptr 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 @@ const char kErrorMessage[] = "error message"; } TEST(MessageTest, GetAndSetHeaders) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); EXPECT_EQ("", message->GetDestination()); EXPECT_EQ(ObjectPath(std::string()), message->GetPath()); @@ -646,7 +645,7 @@ TEST(MessageTest, GetAndSetHeaders) { } TEST(MessageTest, SetInvalidHeaders) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); EXPECT_EQ("", message->GetDestination()); EXPECT_EQ(ObjectPath(std::string()), message->GetPath()); EXPECT_EQ("", message->GetInterface()); @@ -678,7 +677,7 @@ TEST(MessageTest, SetInvalidHeaders) { TEST(MessageTest, ToString_LongString) { const std::string kLongString(1000, 'o'); - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr 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 66f485ad06ff31..f27f6f6acced3e 100644 --- a/dbus/mock_object_proxy.h +++ b/dbus/mock_object_proxy.h @@ -21,27 +21,28 @@ class MockObjectProxy : public ObjectProxy { 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 CallMethodAndBlockWithErrorDetails( + std::unique_ptr CallMethodAndBlockWithErrorDetails( MethodCall* method_call, int timeout_ms, ScopedDBusError* error) override { - return scoped_ptr( + return std::unique_ptr( MockCallMethodAndBlockWithErrorDetails(method_call, timeout_ms, error)); } MOCK_METHOD2(MockCallMethodAndBlock, Response*(MethodCall* method_call, int timeout_ms)); - scoped_ptr CallMethodAndBlock(MethodCall* method_call, - int timeout_ms) override { - return scoped_ptr(MockCallMethodAndBlock(method_call, - timeout_ms)); + std::unique_ptr CallMethodAndBlock(MethodCall* method_call, + int timeout_ms) override { + return std::unique_ptr( + 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 6b2a521127aa1e..ed78e2cb4eb788 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 + #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 @@ class MockTest : public testing::Test { protected: std::string response_string_; base::MessageLoop message_loop_; - scoped_ptr run_loop_; + std::unique_ptr run_loop_; scoped_refptr mock_bus_; scoped_refptr mock_proxy_; @@ -96,7 +97,7 @@ class MockTest : public testing::Test { MessageReader reader(method_call); std::string text_message; if (reader.PopString(&text_message)) { - scoped_ptr response = Response::CreateEmpty(); + std::unique_ptr response = Response::CreateEmpty(); MessageWriter writer(response.get()); writer.AppendString(text_message); return response.release(); @@ -151,9 +152,8 @@ TEST_F(MockTest, CallMethodAndBlock) { writer.AppendString(kHello); // Call the method. - scoped_ptr response( - proxy->CallMethodAndBlock(&method_call, - ObjectProxy::TIMEOUT_USE_DEFAULT)); + std::unique_ptr response(proxy->CallMethodAndBlock( + &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT)); // Check the response. ASSERT_TRUE(response.get()); @@ -175,9 +175,8 @@ TEST_F(MockTest, CallMethodAndBlockWithErrorDetails) { ScopedDBusError error; // Call the method. - scoped_ptr response( - proxy->CallMethodAndBlockWithErrorDetails( - &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT, &error)); + std::unique_ptr 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 9215d84ecf0fa0..56143c758b4bb9 100644 --- a/dbus/object_manager.cc +++ b/dbus/object_manager.cc @@ -263,8 +263,7 @@ DBusHandlerResult ObjectManager::HandleMessage(DBusConnection* connection, // 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::FromRawMessage(raw_message)); + std::unique_ptr 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 443210c98e21f6..ae03776a51df59 100644 --- a/dbus/object_manager_unittest.cc +++ b/dbus/object_manager_unittest.cc @@ -205,11 +205,11 @@ class ObjectManagerTest } base::MessageLoop message_loop_; - scoped_ptr run_loop_; - scoped_ptr dbus_thread_; + std::unique_ptr run_loop_; + std::unique_ptr dbus_thread_; scoped_refptr bus_; ObjectManager* object_manager_; - scoped_ptr test_service_; + std::unique_ptr test_service_; std::string last_name_value_; bool timeout_expired_; diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc index 6c758b9ea9c838..5d9d8e842f0a43 100644 --- a/dbus/object_proxy.cc +++ b/dbus/object_proxy.cc @@ -69,14 +69,16 @@ ObjectProxy::~ObjectProxy() { // 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 ObjectProxy::CallMethodAndBlockWithErrorDetails( - MethodCall* method_call, int timeout_ms, ScopedDBusError* error) { +std::unique_ptr 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(); + return std::unique_ptr(); DBusMessage* request_message = method_call->raw_message(); @@ -97,7 +99,7 @@ scoped_ptr ObjectProxy::CallMethodAndBlockWithErrorDetails( method_call->GetMember(), error->is_set() ? error->name() : "unknown error type", error->is_set() ? error->message() : ""); - return scoped_ptr(); + return std::unique_ptr(); } // Record time spent for the method call. Don't include failures. UMA_HISTOGRAM_TIMES("DBus.SyncMethodCallTime", @@ -106,8 +108,9 @@ scoped_ptr ObjectProxy::CallMethodAndBlockWithErrorDetails( return Response::FromRawMessage(response_message); } -scoped_ptr ObjectProxy::CallMethodAndBlock(MethodCall* method_call, - int timeout_ms) { +std::unique_ptr ObjectProxy::CallMethodAndBlock( + MethodCall* method_call, + int timeout_ms) { ScopedDBusError error; return CallMethodAndBlockWithErrorDetails(method_call, timeout_ms, &error); } @@ -325,7 +328,7 @@ void ObjectProxy::RunResponseCallback(ResponseCallback response_callback, } else if (dbus_message_get_type(response_message) == DBUS_MESSAGE_TYPE_ERROR) { // This will take |response_message| and release (unref) it. - scoped_ptr error_response( + std::unique_ptr 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 @@ void ObjectProxy::RunResponseCallback(ResponseCallback response_callback, error_response.release())); } else { // This will take |response_message| and release (unref) it. - scoped_ptr response(Response::FromRawMessage(response_message)); + std::unique_ptr 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 @@ DBusHandlerResult ObjectProxy::HandleMessage( // 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::FromRawMessage(raw_message)); + std::unique_ptr 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 @@ void ObjectProxy::UpdateNameOwnerAndBlock() { } DBusHandlerResult ObjectProxy::HandleNameOwnerChanged( - scoped_ptr signal) { + std::unique_ptr signal) { DCHECK(signal); bus_->AssertOnDBusThread(); diff --git a/dbus/object_proxy.h b/dbus/object_proxy.h index 839d5f72dc785a..033e88608a0952 100644 --- a/dbus/object_proxy.h +++ b/dbus/object_proxy.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -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 @@ class CHROME_DBUS_EXPORT ObjectProxy // in the |error| object. // // BLOCKING CALL. - virtual scoped_ptr CallMethodAndBlockWithErrorDetails( + virtual std::unique_ptr CallMethodAndBlockWithErrorDetails( MethodCall* method_call, int timeout_ms, ScopedDBusError* error); @@ -107,8 +107,8 @@ class CHROME_DBUS_EXPORT ObjectProxy // is returned. Returns NULL on error. // // BLOCKING CALL. - virtual scoped_ptr CallMethodAndBlock(MethodCall* method_call, - int timeout_ms); + virtual std::unique_ptr CallMethodAndBlock(MethodCall* method_call, + int timeout_ms); // Requests to call the method of the remote object. // @@ -290,7 +290,8 @@ class CHROME_DBUS_EXPORT ObjectProxy void UpdateNameOwnerAndBlock(); // Handles NameOwnerChanged signal from D-Bus's special message bus. - DBusHandlerResult HandleNameOwnerChanged(scoped_ptr signal); + DBusHandlerResult HandleNameOwnerChanged( + std::unique_ptr 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 05c12943496889..cc79f849cdc583 100644 --- a/dbus/object_proxy_unittest.cc +++ b/dbus/object_proxy_unittest.cc @@ -29,7 +29,7 @@ class ObjectProxyTest : public testing::Test { }; // Used as a WaitForServiceToBeAvailableCallback. -void OnServiceIsAvailable(scoped_ptr* run_loop, +void OnServiceIsAvailable(std::unique_ptr* run_loop, bool service_is_available) { EXPECT_TRUE(service_is_available); ASSERT_TRUE(*run_loop); @@ -37,7 +37,7 @@ void OnServiceIsAvailable(scoped_ptr* run_loop, } TEST_F(ObjectProxyTest, WaitForServiceToBeAvailable) { - scoped_ptr run_loop; + std::unique_ptr run_loop; TestService::Options options; TestService test_service(options); diff --git a/dbus/property.cc b/dbus/property.cc index 66af86676cb8ed..faca4a0a1d76dd 100644 --- a/dbus/property.cc +++ b/dbus/property.cc @@ -141,9 +141,8 @@ bool PropertySet::GetAndBlock(PropertyBase* property) { writer.AppendString(property->name()); DCHECK(object_proxy_); - scoped_ptr response( - object_proxy_->CallMethodAndBlock(&method_call, - ObjectProxy::TIMEOUT_USE_DEFAULT)); + std::unique_ptr response(object_proxy_->CallMethodAndBlock( + &method_call, ObjectProxy::TIMEOUT_USE_DEFAULT)); if (!response.get()) { LOG(WARNING) << property->name() << ": GetAndBlock: failed."; @@ -212,9 +211,8 @@ bool PropertySet::SetAndBlock(PropertyBase* property) { property->AppendSetValueToWriter(&writer); DCHECK(object_proxy_); - scoped_ptr response( - object_proxy_->CallMethodAndBlock(&method_call, - ObjectProxy::TIMEOUT_USE_DEFAULT)); + std::unique_ptr 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 f1592849aef12f..5922554f23d425 100644 --- a/dbus/property_unittest.cc +++ b/dbus/property_unittest.cc @@ -158,12 +158,12 @@ class PropertyTest : public testing::Test { } base::MessageLoop message_loop_; - scoped_ptr run_loop_; - scoped_ptr dbus_thread_; + std::unique_ptr run_loop_; + std::unique_ptr dbus_thread_; scoped_refptr bus_; ObjectProxy* object_proxy_; - scoped_ptr properties_; - scoped_ptr test_service_; + std::unique_ptr properties_; + std::unique_ptr test_service_; // Properties updated. std::vector updated_properties_; // Last callback received. @@ -328,7 +328,7 @@ TEST_F(PropertyTest, Invalidate) { } TEST(PropertyTestStatic, ReadWriteStringMap) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); MessageWriter variant_writer(NULL); MessageWriter variant_array_writer(NULL); @@ -362,7 +362,7 @@ TEST(PropertyTestStatic, SerializeStringMap) { test_map["Map"] = "Test"; test_map["Random"] = "Text"; - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); Property> string_map; @@ -375,7 +375,7 @@ TEST(PropertyTestStatic, SerializeStringMap) { } TEST(PropertyTestStatic, ReadWriteNetAddressArray) { - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); MessageWriter variant_writer(NULL); MessageWriter variant_array_writer(NULL); @@ -419,7 +419,7 @@ TEST(PropertyTestStatic, SerializeNetAddressArray) { test_list.push_back(make_pair(bytes, 16)); } - scoped_ptr message(Response::CreateEmpty()); + std::unique_ptr message(Response::CreateEmpty()); MessageWriter writer(message.get()); Property, uint16_t>>> ip_list; diff --git a/dbus/signal_sender_verification_unittest.cc b/dbus/signal_sender_verification_unittest.cc index 785948a1f2b3b8..3b2cf6f50737ac 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 + #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 @@ class SignalSenderVerificationTest : public testing::Test { } base::MessageLoop message_loop_; - scoped_ptr run_loop_; - scoped_ptr dbus_thread_; + std::unique_ptr run_loop_; + std::unique_ptr dbus_thread_; scoped_refptr bus_; ObjectProxy* object_proxy_; - scoped_ptr test_service_; - scoped_ptr test_service2_; + std::unique_ptr test_service_; + std::unique_ptr test_service2_; // Text message from "Test" signal. std::string test_signal_string_; @@ -201,7 +202,7 @@ TEST_F(SignalSenderVerificationTest, DISABLED_TestSignalRejected) { UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 0); base::HistogramBase* reject_signal_histogram = base::StatisticsRecorder::FindHistogram("DBus.RejectedSignalCount"); - scoped_ptr samples1( + std::unique_ptr samples1( reject_signal_histogram->SnapshotSamples()); const char kNewMessage[] = "hello, new world"; @@ -211,7 +212,7 @@ TEST_F(SignalSenderVerificationTest, DISABLED_TestSignalRejected) { // Sleep to have message delivered to the client via the D-Bus service. base::PlatformThread::Sleep(TestTimeouts::action_timeout()); - scoped_ptr samples2( + std::unique_ptr samples2( reject_signal_histogram->SnapshotSamples()); ASSERT_EQ("", test_signal_string_); diff --git a/dbus/test_service.cc b/dbus/test_service.cc index 7b36082b66cb66..217e8ee7591299 100644 --- a/dbus/test_service.cc +++ b/dbus/test_service.cc @@ -309,11 +309,11 @@ void TestService::Echo(MethodCall* method_call, MessageReader reader(method_call); std::string text_message; if (!reader.PopString(&text_message)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); writer.AppendString(text_message); response_sender.Run(std::move(response)); @@ -338,7 +338,7 @@ void TestService::AsyncEcho(MethodCall* method_call, void TestService::BrokenMethod(MethodCall* method_call, ExportedObject::ResponseSender response_sender) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); } @@ -348,11 +348,11 @@ void TestService::GetAllProperties( MessageReader reader(method_call); std::string interface; if (!reader.PopString(&interface)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); AddPropertiesToWriter(&writer); @@ -365,20 +365,20 @@ void TestService::GetProperty(MethodCall* method_call, MessageReader reader(method_call); std::string interface; if (!reader.PopString(&interface)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } std::string name; if (!reader.PopString(&name)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } if (name == "Name") { // Return the previous value for the "Name" property: // Variant<"TestService"> - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); writer.AppendVariantOfString("TestService"); @@ -387,7 +387,7 @@ void TestService::GetProperty(MethodCall* method_call, } else if (name == "Version") { // Return a new value for the "Version" property: // Variant<20> - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); writer.AppendVariantOfInt16(20); @@ -396,7 +396,7 @@ void TestService::GetProperty(MethodCall* method_call, } else if (name == "Methods") { // Return the previous value for the "Methods" property: // Variant<["Echo", "SlowEcho", "AsyncEcho", "BrokenMethod"]> - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); MessageWriter variant_writer(NULL); MessageWriter variant_array_writer(NULL); @@ -414,7 +414,7 @@ void TestService::GetProperty(MethodCall* method_call, } else if (name == "Objects") { // Return the previous value for the "Objects" property: // Variant<[objectpath:"/TestObjectPath"]> - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); MessageWriter variant_writer(NULL); MessageWriter variant_array_writer(NULL); @@ -429,7 +429,7 @@ void TestService::GetProperty(MethodCall* method_call, } else if (name == "Bytes") { // Return the previous value for the "Bytes" property: // Variant<[0x54, 0x65, 0x73, 0x74]> - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); MessageWriter variant_writer(NULL); MessageWriter variant_array_writer(NULL); @@ -442,7 +442,7 @@ void TestService::GetProperty(MethodCall* method_call, response_sender.Run(std::move(response)); } else { // Return error. - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } } @@ -452,24 +452,24 @@ void TestService::SetProperty(MethodCall* method_call, MessageReader reader(method_call); std::string interface; if (!reader.PopString(&interface)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } std::string name; if (!reader.PopString(&name)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } if (name != "Name") { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } std::string value; if (!reader.PopVariantOfString(&value)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } @@ -485,7 +485,7 @@ void TestService::PerformAction( std::string action; ObjectPath object_path; if (!reader.PopString(&action) || !reader.PopObjectPath(&object_path)) { - response_sender.Run(scoped_ptr()); + response_sender.Run(std::unique_ptr()); return; } @@ -509,14 +509,14 @@ void TestService::PerformAction( SendPropertyInvalidatedSignal(); } - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); response_sender.Run(std::move(response)); } void TestService::PerformActionResponse( MethodCall* method_call, ExportedObject::ResponseSender response_sender) { - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); response_sender.Run(std::move(response)); } @@ -540,7 +540,7 @@ void TestService::OwnershipRegained( void TestService::GetManagedObjects( MethodCall* method_call, ExportedObject::ResponseSender response_sender) { - scoped_ptr response = Response::FromMethodCall(method_call); + std::unique_ptr response = Response::FromMethodCall(method_call); MessageWriter writer(response.get()); // The managed objects response is a dictionary of object paths identifying diff --git a/dbus/values_util.cc b/dbus/values_util.cc index e932312e692984..ed435a193680ff 100644 --- a/dbus/values_util.cc +++ b/dbus/values_util.cc @@ -4,9 +4,10 @@ #include "dbus/values_util.h" +#include + #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 @@ bool PopDictionaryEntries(MessageReader* reader, return false; } else { // If the type of keys is not STRING, convert it to string. - scoped_ptr key(PopDataAsValue(&entry_reader)); + std::unique_ptr key(PopDataAsValue(&entry_reader)); if (!key) return false; // Use JSONWriter to convert an arbitrary value to a string. @@ -176,12 +177,12 @@ base::Value* PopDataAsValue(MessageReader* reader) { // 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 dictionary_value( + std::unique_ptr dictionary_value( new base::DictionaryValue); if (PopDictionaryEntries(&sub_reader, dictionary_value.get())) result = dictionary_value.release(); } else { - scoped_ptr list_value(new base::ListValue); + std::unique_ptr list_value(new base::ListValue); if (PopListElements(&sub_reader, list_value.get())) result = list_value.release(); } @@ -191,7 +192,7 @@ base::Value* PopDataAsValue(MessageReader* reader) { case Message::STRUCT: { MessageReader sub_reader(NULL); if (reader->PopStruct(&sub_reader)) { - scoped_ptr list_value(new base::ListValue); + std::unique_ptr 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 b2f1404da45f94..6903d51d20dbb7 100644 --- a/dbus/values_util_unittest.cc +++ b/dbus/values_util_unittest.cc @@ -8,11 +8,11 @@ #include #include +#include #include #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::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append basic type values. MessageWriter writer(response.get()); const uint8_t kByteValue = 42; @@ -49,8 +49,8 @@ TEST(ValuesUtilTest, PopBasicTypes) { writer.AppendObjectPath(kObjectPathValue); MessageReader reader(response.get()); - scoped_ptr value; - scoped_ptr expected_value; + std::unique_ptr value; + std::unique_ptr expected_value; // Pop a byte. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); @@ -117,7 +117,7 @@ TEST(ValuesUtilTest, PopBasicTypes) { } TEST(ValuesUtilTest, PopVariant) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append variant values. MessageWriter writer(response.get()); const bool kBoolValue = true; @@ -130,8 +130,8 @@ TEST(ValuesUtilTest, PopVariant) { writer.AppendVariantOfString(kStringValue); MessageReader reader(response.get()); - scoped_ptr value; - scoped_ptr expected_value; + std::unique_ptr value; + std::unique_ptr expected_value; // Pop a bool. value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); @@ -157,7 +157,7 @@ TEST(ValuesUtilTest, PopVariant) { // Pop extremely large integers which cannot be precisely represented in // double. TEST(ValuesUtilTest, PopExtremelyLargeIntegers) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append large integers. MessageWriter writer(response.get()); const int64_t kInt64Value = -123456789012345689LL; @@ -166,8 +166,8 @@ TEST(ValuesUtilTest, PopExtremelyLargeIntegers) { writer.AppendUint64(kUint64Value); MessageReader reader(response.get()); - scoped_ptr value; - scoped_ptr expected_value; + std::unique_ptr value; + std::unique_ptr expected_value; double double_value = 0; // Pop an int64_t. value.reset(PopDataAsValue(&reader)); @@ -188,7 +188,7 @@ TEST(ValuesUtilTest, PopExtremelyLargeIntegers) { } TEST(ValuesUtilTest, PopIntArray) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append an int32_t array. MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); @@ -202,19 +202,19 @@ TEST(ValuesUtilTest, PopIntArray) { writer.CloseContainer(&sub_writer); // Create the expected value. - scoped_ptr list_value(new base::ListValue); + std::unique_ptr 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 value(PopDataAsValue(&reader)); + std::unique_ptr value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(list_value.get())); } TEST(ValuesUtilTest, PopStringArray) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append a string array. MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); @@ -225,19 +225,19 @@ TEST(ValuesUtilTest, PopStringArray) { writer.AppendArrayOfStrings(data); // Create the expected value. - scoped_ptr list_value(new base::ListValue); + std::unique_ptr 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 value(PopDataAsValue(&reader)); + std::unique_ptr value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(list_value.get())); } TEST(ValuesUtilTest, PopStruct) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append a struct. MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); @@ -261,13 +261,13 @@ TEST(ValuesUtilTest, PopStruct) { // Pop a struct. MessageReader reader(response.get()); - scoped_ptr value(PopDataAsValue(&reader)); + std::unique_ptr value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&list_value)); } TEST(ValuesUtilTest, PopStringToVariantDictionary) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append a dictionary. MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); @@ -308,13 +308,13 @@ TEST(ValuesUtilTest, PopStringToVariantDictionary) { // Pop a dictinoary. MessageReader reader(response.get()); - scoped_ptr value(PopDataAsValue(&reader)); + std::unique_ptr value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&dictionary_value)); } TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) { - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); // Append a dictionary. MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); @@ -351,7 +351,7 @@ TEST(ValuesUtilTest, PopDictionaryWithDottedStringKey) { // Pop a dictinoary. MessageReader reader(response.get()); - scoped_ptr value(PopDataAsValue(&reader)); + std::unique_ptr value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&dictionary_value)); } @@ -365,7 +365,7 @@ TEST(ValuesUtilTest, PopDoubleToIntDictionary) { keys[i] = std::sqrt(values[i]); // Append a dictionary. - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); MessageWriter sub_writer(NULL); writer.OpenArray("{di}", &sub_writer); @@ -388,7 +388,7 @@ TEST(ValuesUtilTest, PopDoubleToIntDictionary) { // Pop a dictionary. MessageReader reader(response.get()); - scoped_ptr value(PopDataAsValue(&reader)); + std::unique_ptr value(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&dictionary_value)); } @@ -399,7 +399,7 @@ TEST(ValuesUtilTest, AppendBasicTypes) { const base::FundamentalValue kDoubleValue(4.2); const base::StringValue kStringValue("string"); - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendBasicTypeValueData(&writer, kBoolValue); AppendBasicTypeValueData(&writer, kIntegerValue); @@ -407,7 +407,7 @@ TEST(ValuesUtilTest, AppendBasicTypes) { AppendBasicTypeValueData(&writer, kStringValue); MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&kBoolValue)); @@ -428,7 +428,7 @@ TEST(ValuesUtilTest, AppendBasicTypesAsVariant) { const base::FundamentalValue kDoubleValue(4.2); const base::StringValue kStringValue("string"); - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendBasicTypeValueDataAsVariant(&writer, kBoolValue); AppendBasicTypeValueDataAsVariant(&writer, kIntegerValue); @@ -436,7 +436,7 @@ TEST(ValuesUtilTest, AppendBasicTypesAsVariant) { AppendBasicTypeValueDataAsVariant(&writer, kStringValue); MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&kBoolValue)); @@ -457,7 +457,7 @@ TEST(ValuesUtilTest, AppendValueDataBasicTypes) { const base::FundamentalValue kDoubleValue(4.2); const base::StringValue kStringValue("string"); - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendValueData(&writer, kBoolValue); AppendValueData(&writer, kIntegerValue); @@ -465,7 +465,7 @@ TEST(ValuesUtilTest, AppendValueDataBasicTypes) { AppendValueData(&writer, kStringValue); MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&kBoolValue)); @@ -486,7 +486,7 @@ TEST(ValuesUtilTest, AppendValueDataAsVariantBasicTypes) { const base::FundamentalValue kDoubleValue(4.2); const base::StringValue kStringValue("string"); - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendValueDataAsVariant(&writer, kBoolValue); AppendValueDataAsVariant(&writer, kIntegerValue); @@ -494,7 +494,7 @@ TEST(ValuesUtilTest, AppendValueDataAsVariantBasicTypes) { AppendValueDataAsVariant(&writer, kStringValue); MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&kBoolValue)); @@ -539,7 +539,7 @@ TEST(ValuesUtilTest, AppendDictionary) { test_dictionary.Set(kKey5, list_value); // takes ownership test_dictionary.Set(kKey6, dictionary_value); // takes ownership - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendValueData(&writer, test_dictionary); base::FundamentalValue int_value(kInt32Value); @@ -547,7 +547,7 @@ TEST(ValuesUtilTest, AppendDictionary) { // Read the data. MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&test_dictionary)); @@ -586,7 +586,7 @@ TEST(ValuesUtilTest, AppendDictionaryAsVariant) { test_dictionary.Set(kKey5, list_value); // takes ownership test_dictionary.Set(kKey6, dictionary_value); // takes ownership - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendValueDataAsVariant(&writer, test_dictionary); base::FundamentalValue int_value(kInt32Value); @@ -594,7 +594,7 @@ TEST(ValuesUtilTest, AppendDictionaryAsVariant) { // Read the data. MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&test_dictionary)); @@ -629,7 +629,7 @@ TEST(ValuesUtilTest, AppendList) { test_list.Append(list_value); // takes ownership test_list.Append(dictionary_value); // takes ownership - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendValueData(&writer, test_list); base::FundamentalValue int_value(kInt32Value); @@ -637,7 +637,7 @@ TEST(ValuesUtilTest, AppendList) { // Read the data. MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&test_list)); @@ -672,7 +672,7 @@ TEST(ValuesUtilTest, AppendListAsVariant) { test_list.Append(list_value); // takes ownership test_list.Append(dictionary_value); // takes ownership - scoped_ptr response(Response::CreateEmpty()); + std::unique_ptr response(Response::CreateEmpty()); MessageWriter writer(response.get()); AppendValueDataAsVariant(&writer, test_list); base::FundamentalValue int_value(kInt32Value); @@ -680,7 +680,7 @@ TEST(ValuesUtilTest, AppendListAsVariant) { // Read the data. MessageReader reader(response.get()); - scoped_ptr value; + std::unique_ptr value; value.reset(PopDataAsValue(&reader)); ASSERT_TRUE(value.get() != NULL); EXPECT_TRUE(value->Equals(&test_list)); diff --git a/device/bluetooth/dbus/bluetooth_adapter_client.h b/device/bluetooth/dbus/bluetooth_adapter_client.h index 2893954eee24dc..7c3ead73ab8a3b 100644 --- a/device/bluetooth/dbus/bluetooth_adapter_client.h +++ b/device/bluetooth/dbus/bluetooth_adapter_client.h @@ -12,6 +12,7 @@ #include "base/callback.h" #include "base/macros.h" +#include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/values.h" #include "dbus/object_path.h" diff --git a/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h index 7bd43188acb6a9..42a480e9dd48a5 100644 --- a/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h +++ b/device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h @@ -12,6 +12,7 @@ #include "base/callback.h" #include "base/macros.h" +#include "base/memory/scoped_ptr.h" #include "dbus/bus.h" #include "dbus/message.h" #include "dbus/object_path.h" diff --git a/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc b/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc index 9083b6bf9565db..2f6b814fb60afb 100644 --- a/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc @@ -6,6 +6,7 @@ #include "base/location.h" #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/time.h" diff --git a/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h index 49727cb37c2f10..e1f61db933ece4 100644 --- a/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h @@ -11,6 +11,7 @@ #include #include "base/macros.h" +#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "dbus/object_path.h"