[go: nahoru, domu]

Convert Callbacks to OnceCallbacks for read/write in BluetoothGattDescriptor

This will allow us to convert more Callbacks in the bluetooth component
over to OnceCallbacks, which will let us convert Callbacks in content
eventually.

R=reillyg@chromium.org

Bug: 953861
Change-Id: I9b42c51d54147817fefd5e80b262d51c37eb02f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574605
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653233}
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_winrt.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_winrt.cc
index ca05ae7..85532b7 100644
--- a/device/bluetooth/bluetooth_remote_gatt_descriptor_winrt.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_winrt.cc
@@ -98,7 +98,7 @@
 }
 
 void BluetoothRemoteGattDescriptorWinrt::ReadRemoteDescriptor(
-    const ValueCallback& callback,
+    ValueCallback callback,
     ErrorCallback error_callback) {
   if (pending_read_callbacks_ || pending_write_callbacks_) {
     base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -137,12 +137,12 @@
   }
 
   pending_read_callbacks_ = std::make_unique<PendingReadCallbacks>(
-      callback, std::move(error_callback));
+      std::move(callback), std::move(error_callback));
 }
 
 void BluetoothRemoteGattDescriptorWinrt::WriteRemoteDescriptor(
     const std::vector<uint8_t>& value,
-    const base::Closure& callback,
+    base::OnceClosure callback,
     ErrorCallback error_callback) {
   if (pending_read_callbacks_ || pending_write_callbacks_) {
     base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -205,7 +205,7 @@
   }
 
   pending_write_callbacks_ = std::make_unique<PendingWriteCallbacks>(
-      callback, std::move(error_callback));
+      std::move(callback), std::move(error_callback));
 }
 
 IGattDescriptor* BluetoothRemoteGattDescriptorWinrt::GetDescriptorForTesting() {
@@ -307,7 +307,7 @@
   }
 
   value_.assign(data, data + length);
-  pending_read_callbacks->callback.Run(value_);
+  std::move(pending_read_callbacks->callback).Run(value_);
 }
 
 void BluetoothRemoteGattDescriptorWinrt::OnWriteValueWithResult(