OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/usb/usb_device_handle_impl.h" | 5 #include "device/usb/usb_device_handle_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <numeric> | 9 #include <numeric> |
10 #include <utility> | 10 #include <utility> |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 } | 855 } |
856 | 856 |
857 void UsbDeviceHandleImpl::ClaimInterfaceComplete( | 857 void UsbDeviceHandleImpl::ClaimInterfaceComplete( |
858 scoped_refptr<InterfaceClaimer> interface_claimer, | 858 scoped_refptr<InterfaceClaimer> interface_claimer, |
859 const ResultCallback& callback) { | 859 const ResultCallback& callback) { |
860 if (interface_claimer) { | 860 if (interface_claimer) { |
861 claimed_interfaces_[interface_claimer->interface_number()] = | 861 claimed_interfaces_[interface_claimer->interface_number()] = |
862 interface_claimer; | 862 interface_claimer; |
863 RefreshEndpointMap(); | 863 RefreshEndpointMap(); |
864 } | 864 } |
865 callback.Run(interface_claimer); | 865 callback.Run(static_cast<bool>(interface_claimer)); |
866 } | 866 } |
867 | 867 |
868 void UsbDeviceHandleImpl::SetInterfaceAlternateSettingOnBlockingThread( | 868 void UsbDeviceHandleImpl::SetInterfaceAlternateSettingOnBlockingThread( |
869 int interface_number, | 869 int interface_number, |
870 int alternate_setting, | 870 int alternate_setting, |
871 const ResultCallback& callback) { | 871 const ResultCallback& callback) { |
872 int rv = libusb_set_interface_alt_setting(handle_, interface_number, | 872 int rv = libusb_set_interface_alt_setting(handle_, interface_number, |
873 alternate_setting); | 873 alternate_setting); |
874 if (rv != LIBUSB_SUCCESS) { | 874 if (rv != LIBUSB_SUCCESS) { |
875 USB_LOG(EVENT) << "Failed to set interface " << interface_number | 875 USB_LOG(EVENT) << "Failed to set interface " << interface_number |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 } else { | 1121 } else { |
1122 transfer->callback_task_runner()->PostTask(FROM_HERE, callback); | 1122 transfer->callback_task_runner()->PostTask(FROM_HERE, callback); |
1123 } | 1123 } |
1124 | 1124 |
1125 // libusb_free_transfer races with libusb_submit_transfer and only work- | 1125 // libusb_free_transfer races with libusb_submit_transfer and only work- |
1126 // around is to make sure to call them on the same thread. | 1126 // around is to make sure to call them on the same thread. |
1127 blocking_task_runner_->DeleteSoon(FROM_HERE, transfer); | 1127 blocking_task_runner_->DeleteSoon(FROM_HERE, transfer); |
1128 } | 1128 } |
1129 | 1129 |
1130 } // namespace device | 1130 } // namespace device |
OLD | NEW |