OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/webusb/USBInterface.h" | 5 #include "modules/webusb/USBInterface.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "device/usb/public/interfaces/device.mojom-blink.h" | 8 #include "device/usb/public/interfaces/device.mojom-blink.h" |
9 #include "modules/webusb/USBAlternateInterface.h" | 9 #include "modules/webusb/USBAlternateInterface.h" |
10 #include "modules/webusb/USBConfiguration.h" | 10 #include "modules/webusb/USBConfiguration.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 size_t interface_index) | 36 size_t interface_index) |
37 : device_(device), | 37 : device_(device), |
38 configuration_index_(configuration_index), | 38 configuration_index_(configuration_index), |
39 interface_index_(interface_index) { | 39 interface_index_(interface_index) { |
40 ASSERT(configuration_index_ < device_->Info().configurations.size()); | 40 ASSERT(configuration_index_ < device_->Info().configurations.size()); |
41 ASSERT( | 41 ASSERT( |
42 interface_index_ < | 42 interface_index_ < |
43 device_->Info().configurations[configuration_index_]->interfaces.size()); | 43 device_->Info().configurations[configuration_index_]->interfaces.size()); |
44 } | 44 } |
45 | 45 |
46 const device::usb::blink::InterfaceInfo& USBInterface::Info() const { | 46 const device::mojom::blink::UsbInterfaceInfo& USBInterface::Info() const { |
47 return *device_->Info() | 47 return *device_->Info() |
48 .configurations[configuration_index_] | 48 .configurations[configuration_index_] |
49 ->interfaces[interface_index_]; | 49 ->interfaces[interface_index_]; |
50 } | 50 } |
51 | 51 |
52 USBAlternateInterface* USBInterface::alternate() const { | 52 USBAlternateInterface* USBInterface::alternate() const { |
53 if (device_->IsInterfaceClaimed(configuration_index_, interface_index_)) | 53 if (device_->IsInterfaceClaimed(configuration_index_, interface_index_)) |
54 return USBAlternateInterface::Create( | 54 return USBAlternateInterface::Create( |
55 this, device_->SelectedAlternateInterface(interface_index_)); | 55 this, device_->SelectedAlternateInterface(interface_index_)); |
56 return nullptr; | 56 return nullptr; |
57 } | 57 } |
58 | 58 |
59 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const { | 59 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const { |
60 HeapVector<Member<USBAlternateInterface>> alternates; | 60 HeapVector<Member<USBAlternateInterface>> alternates; |
61 for (size_t i = 0; i < Info().alternates.size(); ++i) | 61 for (size_t i = 0; i < Info().alternates.size(); ++i) |
62 alternates.push_back(USBAlternateInterface::Create(this, i)); | 62 alternates.push_back(USBAlternateInterface::Create(this, i)); |
63 return alternates; | 63 return alternates; |
64 } | 64 } |
65 | 65 |
66 bool USBInterface::claimed() const { | 66 bool USBInterface::claimed() const { |
67 return device_->IsInterfaceClaimed(configuration_index_, interface_index_); | 67 return device_->IsInterfaceClaimed(configuration_index_, interface_index_); |
68 } | 68 } |
69 | 69 |
70 DEFINE_TRACE(USBInterface) { | 70 DEFINE_TRACE(USBInterface) { |
71 visitor->Trace(device_); | 71 visitor->Trace(device_); |
72 } | 72 } |
73 | 73 |
74 } // namespace blink | 74 } // namespace blink |
OLD | NEW |