Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: device/bluetooth/bluetooth_task_manager_win.cc

Issue 2941193002: Fix unique_ptr usage warning in bluetooth_task_manager_win.cc. (Closed)
Patch Set: static_cast to reinterpret_cast Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_task_manager_win.h" 5 #include "device/bluetooth/bluetooth_task_manager_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <winsock2.h> 8 #include <winsock2.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 FROM_HERE, 857 FROM_HERE,
858 base::Bind(callback, base::Passed(&win_characteristic_value), hr)); 858 base::Bind(callback, base::Passed(&win_characteristic_value), hr));
859 } 859 }
860 860
861 void BluetoothTaskManagerWin::WriteGattCharacteristicValue( 861 void BluetoothTaskManagerWin::WriteGattCharacteristicValue(
862 base::FilePath service_path, 862 base::FilePath service_path,
863 BTH_LE_GATT_CHARACTERISTIC characteristic, 863 BTH_LE_GATT_CHARACTERISTIC characteristic,
864 std::vector<uint8_t> new_value, 864 std::vector<uint8_t> new_value,
865 const HResultCallback& callback) { 865 const HResultCallback& callback) {
866 ULONG length = (ULONG)(sizeof(ULONG) + new_value.size()); 866 ULONG length = (ULONG)(sizeof(ULONG) + new_value.size());
867 std::unique_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> win_new_value( 867 std::vector<UCHAR> data(length);
868 (PBTH_LE_GATT_CHARACTERISTIC_VALUE)(new UCHAR[length])); 868 auto* win_new_value =
869 reinterpret_cast<PBTH_LE_GATT_CHARACTERISTIC_VALUE>(&data[0]);
869 win_new_value->DataSize = (ULONG)new_value.size(); 870 win_new_value->DataSize = (ULONG)new_value.size();
870 for (ULONG i = 0; i < new_value.size(); i++) 871 for (ULONG i = 0; i < new_value.size(); i++)
871 win_new_value->Data[i] = new_value[i]; 872 win_new_value->Data[i] = new_value[i];
872 873
873 HRESULT hr = 874 HRESULT hr =
874 win::BluetoothLowEnergyWrapper::GetInstance()->WriteCharacteristicValue( 875 win::BluetoothLowEnergyWrapper::GetInstance()->WriteCharacteristicValue(
875 service_path, (PBTH_LE_GATT_CHARACTERISTIC)(&characteristic), 876 service_path, (PBTH_LE_GATT_CHARACTERISTIC)(&characteristic),
876 win_new_value.get()); 877 win_new_value);
877 878
878 ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, hr)); 879 ui_task_runner_->PostTask(FROM_HERE, base::Bind(callback, hr));
879 } 880 }
880 881
881 void BluetoothTaskManagerWin::RegisterGattCharacteristicValueChangedEvent( 882 void BluetoothTaskManagerWin::RegisterGattCharacteristicValueChangedEvent(
882 base::FilePath service_path, 883 base::FilePath service_path,
883 BTH_LE_GATT_CHARACTERISTIC characteristic, 884 BTH_LE_GATT_CHARACTERISTIC characteristic,
884 BTH_LE_GATT_DESCRIPTOR ccc_descriptor, 885 BTH_LE_GATT_DESCRIPTOR ccc_descriptor,
885 const GattEventRegistrationCallback& callback, 886 const GattEventRegistrationCallback& callback,
886 const GattCharacteristicValueChangedCallback& registered_callback) { 887 const GattCharacteristicValueChangedCallback& registered_callback) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 void BluetoothTaskManagerWin::PostUnregisterGattCharacteristicValueChangedEvent( 1009 void BluetoothTaskManagerWin::PostUnregisterGattCharacteristicValueChangedEvent(
1009 PVOID event_handle) { 1010 PVOID event_handle) {
1010 DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); 1011 DCHECK(ui_task_runner_->RunsTasksInCurrentSequence());
1011 bluetooth_task_runner_->PostTask( 1012 bluetooth_task_runner_->PostTask(
1012 FROM_HERE, base::Bind(&BluetoothTaskManagerWin:: 1013 FROM_HERE, base::Bind(&BluetoothTaskManagerWin::
1013 UnregisterGattCharacteristicValueChangedEvent, 1014 UnregisterGattCharacteristicValueChangedEvent,
1014 this, event_handle)); 1015 this, event_handle));
1015 } 1016 }
1016 1017
1017 } // namespace device 1018 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698