Index: extensions/browser/api/hid/hid_api.cc |
diff --git a/extensions/browser/api/hid/hid_api.cc b/extensions/browser/api/hid/hid_api.cc |
index bbf59b8746dd496b5024103737422cd4c59f72ba..b03ae8baaa7b704bd1e59158372d69b6c36e2dd3 100644 |
--- a/extensions/browser/api/hid/hid_api.cc |
+++ b/extensions/browser/api/hid/hid_api.cc |
@@ -7,8 +7,10 @@ |
#include <stdint.h> |
#include <string> |
+#include <utility> |
#include <vector> |
+#include "base/memory/ptr_util.h" |
#include "device/core/device_client.h" |
#include "device/hid/hid_connection.h" |
#include "device/hid/hid_device_filter.h" |
@@ -56,11 +58,12 @@ const char kErrorFailedToOpenDevice[] = "Failed to open HID device."; |
const char kErrorConnectionNotFound[] = "Connection not established."; |
const char kErrorTransfer[] = "Transfer failed."; |
-base::Value* PopulateHidConnection(int connection_id, |
- scoped_refptr<HidConnection> connection) { |
+std::unique_ptr<base::Value> PopulateHidConnection( |
+ int connection_id, |
+ scoped_refptr<HidConnection> connection) { |
hid::HidConnectInfo connection_value; |
connection_value.connection_id = connection_id; |
- return connection_value.ToValue().release(); |
+ return connection_value.ToValue(); |
} |
void ConvertHidDeviceFilter(const hid::DeviceFilter& input, |
@@ -119,7 +122,7 @@ ExtensionFunction::ResponseAction HidGetDevicesFunction::Run() { |
void HidGetDevicesFunction::OnEnumerationComplete( |
std::unique_ptr<base::ListValue> devices) { |
- Respond(OneArgument(devices.release())); |
+ Respond(OneArgument(std::move(devices))); |
} |
HidGetUserSelectedDevicesFunction::HidGetUserSelectedDevicesFunction() { |
@@ -135,7 +138,7 @@ ExtensionFunction::ResponseAction HidGetUserSelectedDevicesFunction::Run() { |
content::WebContents* web_contents = GetSenderWebContents(); |
if (!web_contents || !user_gesture()) { |
- return RespondNow(OneArgument(new base::ListValue())); |
+ return RespondNow(OneArgument(base::MakeUnique<base::ListValue>())); |
} |
bool multiple = false; |
@@ -287,9 +290,10 @@ void HidReceiveFunction::OnFinished(bool success, |
DCHECK_GE(size, 1u); |
int report_id = reinterpret_cast<uint8_t*>(buffer->data())[0]; |
- Respond(TwoArguments(new base::FundamentalValue(report_id), |
- base::BinaryValue::CreateWithCopiedBuffer( |
- buffer->data() + 1, size - 1))); |
+ Respond( |
+ TwoArguments(base::MakeUnique<base::FundamentalValue>(report_id), |
+ base::WrapUnique(base::BinaryValue::CreateWithCopiedBuffer( |
+ buffer->data() + 1, size - 1)))); |
} else { |
Respond(Error(kErrorTransfer)); |
} |
@@ -346,8 +350,8 @@ void HidReceiveFeatureReportFunction::OnFinished( |
scoped_refptr<net::IOBuffer> buffer, |
size_t size) { |
if (success) { |
- Respond(OneArgument( |
- base::BinaryValue::CreateWithCopiedBuffer(buffer->data(), size))); |
+ Respond(OneArgument(base::WrapUnique( |
+ base::BinaryValue::CreateWithCopiedBuffer(buffer->data(), size)))); |
} else { |
Respond(Error(kErrorTransfer)); |
} |