Commit 26137d0c authored by rvargas's avatar rvargas Committed by Commit bot

Remove implicit HANDLE conversions from device.

BUG=416722
R=gdk@chromium.org

Review URL: https://codereview.chromium.org/604613002

Cr-Commit-Position: refs/heads/master@{#297290}
parent e7002da7
...@@ -171,7 +171,7 @@ bool CollectBluetoothLowEnergyDeviceProperty( ...@@ -171,7 +171,7 @@ bool CollectBluetoothLowEnergyDeviceProperty(
std::string* error) { std::string* error) {
DWORD required_length; DWORD required_length;
DEVPROPTYPE prop_type; DEVPROPTYPE prop_type;
BOOL success = SetupDiGetDeviceProperty(device_info_handle, BOOL success = SetupDiGetDeviceProperty(device_info_handle.Get(),
device_info_data, device_info_data,
&key, &key,
&prop_type, &prop_type,
...@@ -184,7 +184,7 @@ bool CollectBluetoothLowEnergyDeviceProperty( ...@@ -184,7 +184,7 @@ bool CollectBluetoothLowEnergyDeviceProperty(
scoped_ptr<uint8_t[]> prop_value(new uint8_t[required_length]); scoped_ptr<uint8_t[]> prop_value(new uint8_t[required_length]);
DWORD actual_length = required_length; DWORD actual_length = required_length;
success = SetupDiGetDeviceProperty(device_info_handle, success = SetupDiGetDeviceProperty(device_info_handle.Get(),
device_info_data, device_info_data,
&key, &key,
&prop_type, &prop_type,
...@@ -211,7 +211,7 @@ bool CollectBluetoothLowEnergyDeviceRegistryProperty( ...@@ -211,7 +211,7 @@ bool CollectBluetoothLowEnergyDeviceRegistryProperty(
scoped_ptr<DeviceRegistryPropertyValue>* value, scoped_ptr<DeviceRegistryPropertyValue>* value,
std::string* error) { std::string* error) {
ULONG required_length = 0; ULONG required_length = 0;
BOOL success = SetupDiGetDeviceRegistryProperty(device_info_handle, BOOL success = SetupDiGetDeviceRegistryProperty(device_info_handle.Get(),
device_info_data, device_info_data,
property_id, property_id,
NULL, NULL,
...@@ -224,7 +224,7 @@ bool CollectBluetoothLowEnergyDeviceRegistryProperty( ...@@ -224,7 +224,7 @@ bool CollectBluetoothLowEnergyDeviceRegistryProperty(
scoped_ptr<uint8_t[]> property_value(new uint8_t[required_length]); scoped_ptr<uint8_t[]> property_value(new uint8_t[required_length]);
ULONG actual_length = required_length; ULONG actual_length = required_length;
DWORD property_type; DWORD property_type;
success = SetupDiGetDeviceRegistryProperty(device_info_handle, success = SetupDiGetDeviceRegistryProperty(device_info_handle.Get(),
device_info_data, device_info_data,
property_id, property_id,
&property_type, &property_type,
...@@ -250,13 +250,13 @@ bool CollectBluetoothLowEnergyDeviceInstanceId( ...@@ -250,13 +250,13 @@ bool CollectBluetoothLowEnergyDeviceInstanceId(
std::string* error) { std::string* error) {
ULONG required_length = 0; ULONG required_length = 0;
BOOL success = SetupDiGetDeviceInstanceId( BOOL success = SetupDiGetDeviceInstanceId(
device_info_handle, device_info_data, NULL, 0, &required_length); device_info_handle.Get(), device_info_data, NULL, 0, &required_length);
if (!CheckInsufficientBuffer(!!success, kDeviceInfoError, error)) if (!CheckInsufficientBuffer(!!success, kDeviceInfoError, error))
return false; return false;
scoped_ptr<WCHAR[]> instance_id(new WCHAR[required_length]); scoped_ptr<WCHAR[]> instance_id(new WCHAR[required_length]);
ULONG actual_length = required_length; ULONG actual_length = required_length;
success = SetupDiGetDeviceInstanceId(device_info_handle, success = SetupDiGetDeviceInstanceId(device_info_handle.Get(),
device_info_data, device_info_data,
instance_id.get(), instance_id.get(),
actual_length, actual_length,
...@@ -417,7 +417,7 @@ bool CollectBluetoothLowEnergyDeviceInfo( ...@@ -417,7 +417,7 @@ bool CollectBluetoothLowEnergyDeviceInfo(
std::string* error) { std::string* error) {
// Retrieve required # of bytes for interface details // Retrieve required # of bytes for interface details
ULONG required_length = 0; ULONG required_length = 0;
BOOL success = SetupDiGetDeviceInterfaceDetail(device_info_handle, BOOL success = SetupDiGetDeviceInterfaceDetail(device_info_handle.Get(),
device_interface_data, device_interface_data,
NULL, NULL,
0, 0,
...@@ -438,7 +438,7 @@ bool CollectBluetoothLowEnergyDeviceInfo( ...@@ -438,7 +438,7 @@ bool CollectBluetoothLowEnergyDeviceInfo(
device_info_data.cbSize = sizeof(SP_DEVINFO_DATA); device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
ULONG actual_length = required_length; ULONG actual_length = required_length;
success = SetupDiGetDeviceInterfaceDetail(device_info_handle, success = SetupDiGetDeviceInterfaceDetail(device_info_handle.Get(),
device_interface_data, device_interface_data,
device_interface_detail_data, device_interface_detail_data,
actual_length, actual_length,
...@@ -486,7 +486,7 @@ DeviceInfoResult EnumerateSingleBluetoothLowEnergyDevice( ...@@ -486,7 +486,7 @@ DeviceInfoResult EnumerateSingleBluetoothLowEnergyDevice(
GUID BluetoothInterfaceGUID = GUID_BLUETOOTHLE_DEVICE_INTERFACE; GUID BluetoothInterfaceGUID = GUID_BLUETOOTHLE_DEVICE_INTERFACE;
SP_DEVICE_INTERFACE_DATA device_interface_data = {0}; SP_DEVICE_INTERFACE_DATA device_interface_data = {0};
device_interface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); device_interface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
BOOL success = ::SetupDiEnumDeviceInterfaces(device_info_handle, BOOL success = ::SetupDiEnumDeviceInterfaces(device_info_handle.Get(),
NULL, NULL,
&BluetoothInterfaceGUID, &BluetoothInterfaceGUID,
device_index, device_index,
......
...@@ -291,7 +291,7 @@ void BluetoothTaskManagerWin::PollAdapter() { ...@@ -291,7 +291,7 @@ void BluetoothTaskManagerWin::PollAdapter() {
if (!discovering_) { if (!discovering_) {
const BLUETOOTH_FIND_RADIO_PARAMS adapter_param = const BLUETOOTH_FIND_RADIO_PARAMS adapter_param =
{ sizeof(BLUETOOTH_FIND_RADIO_PARAMS) }; { sizeof(BLUETOOTH_FIND_RADIO_PARAMS) };
if (adapter_handle_) if (adapter_handle_.IsValid())
adapter_handle_.Close(); adapter_handle_.Close();
HANDLE temp_adapter_handle; HANDLE temp_adapter_handle;
HBLUETOOTH_RADIO_FIND handle = BluetoothFindFirstRadio( HBLUETOOTH_RADIO_FIND handle = BluetoothFindFirstRadio(
...@@ -317,7 +317,7 @@ void BluetoothTaskManagerWin::PollAdapter() { ...@@ -317,7 +317,7 @@ void BluetoothTaskManagerWin::PollAdapter() {
void BluetoothTaskManagerWin::PostAdapterStateToUi() { void BluetoothTaskManagerWin::PostAdapterStateToUi() {
DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread());
AdapterState* state = new AdapterState(); AdapterState* state = new AdapterState();
GetAdapterState(adapter_handle_, state); GetAdapterState(adapter_handle_.Get(), state);
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&BluetoothTaskManagerWin::OnAdapterStateChanged, base::Bind(&BluetoothTaskManagerWin::OnAdapterStateChanged,
...@@ -331,10 +331,11 @@ void BluetoothTaskManagerWin::SetPowered( ...@@ -331,10 +331,11 @@ void BluetoothTaskManagerWin::SetPowered(
const BluetoothAdapter::ErrorCallback& error_callback) { const BluetoothAdapter::ErrorCallback& error_callback) {
DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread());
bool success = false; bool success = false;
if (adapter_handle_) { if (adapter_handle_.IsValid()) {
if (!powered) if (!powered)
BluetoothEnableDiscovery(adapter_handle_, false); BluetoothEnableDiscovery(adapter_handle_.Get(), false);
success = !!BluetoothEnableIncomingConnections(adapter_handle_, powered); success =
!!BluetoothEnableIncomingConnections(adapter_handle_.Get(), powered);
} }
if (success) { if (success) {
...@@ -351,8 +352,8 @@ void BluetoothTaskManagerWin::StartDiscovery() { ...@@ -351,8 +352,8 @@ void BluetoothTaskManagerWin::StartDiscovery() {
FROM_HERE, FROM_HERE,
base::Bind(&BluetoothTaskManagerWin::OnDiscoveryStarted, base::Bind(&BluetoothTaskManagerWin::OnDiscoveryStarted,
this, this,
!!adapter_handle_)); adapter_handle_.IsValid()));
if (!adapter_handle_) if (!adapter_handle_.IsValid())
return; return;
discovering_ = true; discovering_ = true;
...@@ -369,7 +370,7 @@ void BluetoothTaskManagerWin::StopDiscovery() { ...@@ -369,7 +370,7 @@ void BluetoothTaskManagerWin::StopDiscovery() {
void BluetoothTaskManagerWin::DiscoverDevices(int timeout_multiplier) { void BluetoothTaskManagerWin::DiscoverDevices(int timeout_multiplier) {
DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread()); DCHECK(bluetooth_task_runner_->RunsTasksOnCurrentThread());
if (!discovering_ || !adapter_handle_) { if (!discovering_ || !adapter_handle_.IsValid()) {
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&BluetoothTaskManagerWin::OnDiscoveryStopped, this)); base::Bind(&BluetoothTaskManagerWin::OnDiscoveryStopped, this));
......
...@@ -208,7 +208,7 @@ void HidConnectionWin::OnReadComplete(scoped_refptr<net::IOBuffer> buffer, ...@@ -208,7 +208,7 @@ void HidConnectionWin::OnReadComplete(scoped_refptr<net::IOBuffer> buffer,
DWORD bytes_transferred; DWORD bytes_transferred;
if (GetOverlappedResult( if (GetOverlappedResult(
file_, transfer->GetOverlapped(), &bytes_transferred, FALSE)) { file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) {
CompleteRead(buffer, bytes_transferred, callback); CompleteRead(buffer, bytes_transferred, callback);
} else { } else {
VPLOG(1) << "HID read failed"; VPLOG(1) << "HID read failed";
...@@ -228,7 +228,7 @@ void HidConnectionWin::OnReadFeatureComplete( ...@@ -228,7 +228,7 @@ void HidConnectionWin::OnReadFeatureComplete(
DWORD bytes_transferred; DWORD bytes_transferred;
if (GetOverlappedResult( if (GetOverlappedResult(
file_, transfer->GetOverlapped(), &bytes_transferred, FALSE)) { file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) {
scoped_refptr<net::IOBuffer> new_buffer( scoped_refptr<net::IOBuffer> new_buffer(
new net::IOBuffer(bytes_transferred - 1)); new net::IOBuffer(bytes_transferred - 1));
memcpy(new_buffer->data(), buffer->data() + 1, bytes_transferred - 1); memcpy(new_buffer->data(), buffer->data() + 1, bytes_transferred - 1);
...@@ -249,7 +249,7 @@ void HidConnectionWin::OnWriteComplete(const WriteCallback& callback, ...@@ -249,7 +249,7 @@ void HidConnectionWin::OnWriteComplete(const WriteCallback& callback,
DWORD bytes_transferred; DWORD bytes_transferred;
if (GetOverlappedResult( if (GetOverlappedResult(
file_, transfer->GetOverlapped(), &bytes_transferred, FALSE)) { file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) {
callback.Run(true); callback.Run(true);
} else { } else {
VPLOG(1) << "HID write failed"; VPLOG(1) << "HID write failed";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment