| 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 "modules/webusb/USBAlternateInterface.h" | 8 #include "modules/webusb/USBAlternateInterface.h" |
| 9 #include "modules/webusb/USBConfiguration.h" | 9 #include "modules/webusb/USBConfiguration.h" |
| 10 #include "modules/webusb/USBDevice.h" | 10 #include "modules/webusb/USBDevice.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 { | 34 { |
| 35 ASSERT(m_configurationIndex < m_device->info().configurations.size()); | 35 ASSERT(m_configurationIndex < m_device->info().configurations.size()); |
| 36 ASSERT(m_interfaceIndex < m_device->info().configurations[m_configurationInd
ex].interfaces.size()); | 36 ASSERT(m_interfaceIndex < m_device->info().configurations[m_configurationInd
ex].interfaces.size()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 const WebUSBDeviceInfo::Interface& USBInterface::info() const | 39 const WebUSBDeviceInfo::Interface& USBInterface::info() const |
| 40 { | 40 { |
| 41 return m_device->info().configurations[m_configurationIndex].interfaces[m_in
terfaceIndex]; | 41 return m_device->info().configurations[m_configurationIndex].interfaces[m_in
terfaceIndex]; |
| 42 } | 42 } |
| 43 | 43 |
| 44 USBAlternateInterface* USBInterface::alternate() const |
| 45 { |
| 46 if (m_device->isInterfaceClaimed(m_configurationIndex, m_interfaceIndex)) |
| 47 return USBAlternateInterface::create(this, m_device->selectedAlternateIn
terface(m_interfaceIndex)); |
| 48 return nullptr; |
| 49 } |
| 50 |
| 44 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const | 51 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const |
| 45 { | 52 { |
| 46 HeapVector<Member<USBAlternateInterface>> alternates; | 53 HeapVector<Member<USBAlternateInterface>> alternates; |
| 47 for (size_t i = 0; i < info().alternates.size(); ++i) | 54 for (size_t i = 0; i < info().alternates.size(); ++i) |
| 48 alternates.append(USBAlternateInterface::create(this, i)); | 55 alternates.append(USBAlternateInterface::create(this, i)); |
| 49 return alternates; | 56 return alternates; |
| 50 } | 57 } |
| 51 | 58 |
| 52 uint8_t USBInterface::interfaceNumber() const | 59 uint8_t USBInterface::interfaceNumber() const |
| 53 { | 60 { |
| 54 return info().interfaceNumber; | 61 return info().interfaceNumber; |
| 55 } | 62 } |
| 56 | 63 |
| 57 bool USBInterface::claimed() const | 64 bool USBInterface::claimed() const |
| 58 { | 65 { |
| 59 return m_device->isInterfaceClaimed(m_configurationIndex, m_interfaceIndex); | 66 return m_device->isInterfaceClaimed(m_configurationIndex, m_interfaceIndex); |
| 60 } | 67 } |
| 61 | 68 |
| 62 DEFINE_TRACE(USBInterface) | 69 DEFINE_TRACE(USBInterface) |
| 63 { | 70 { |
| 64 visitor->trace(m_device); | 71 visitor->trace(m_device); |
| 65 } | 72 } |
| 66 | 73 |
| 67 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |