| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/webusb/USBInterface.h" | 6 #include "modules/webusb/USBInterface.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "modules/webusb/USBAlternateInterface.h" |
| 9 #include "modules/webusb/USBConfiguration.h" | 10 #include "modules/webusb/USBConfiguration.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t
interfaceIndex) | 14 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t
interfaceIndex) |
| 14 { | 15 { |
| 15 return new USBInterface(configuration, interfaceIndex); | 16 return new USBInterface(configuration, interfaceIndex); |
| 16 } | 17 } |
| 17 | 18 |
| 18 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t
interfaceNumber, ExceptionState& exceptionState) | 19 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t
interfaceNumber, ExceptionState& exceptionState) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 { | 32 { |
| 32 ASSERT(m_configuration); | 33 ASSERT(m_configuration); |
| 33 ASSERT(m_interfaceIndex < m_configuration->info().interfaces.size()); | 34 ASSERT(m_interfaceIndex < m_configuration->info().interfaces.size()); |
| 34 } | 35 } |
| 35 | 36 |
| 36 const WebUSBDeviceInfo::Interface& USBInterface::info() const | 37 const WebUSBDeviceInfo::Interface& USBInterface::info() const |
| 37 { | 38 { |
| 38 return m_configuration->info().interfaces[m_interfaceIndex]; | 39 return m_configuration->info().interfaces[m_interfaceIndex]; |
| 39 } | 40 } |
| 40 | 41 |
| 42 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const |
| 43 { |
| 44 HeapVector<Member<USBAlternateInterface>> alternates; |
| 45 for (size_t i = 0; i < info().alternates.size(); ++i) |
| 46 alternates.append(USBAlternateInterface::create(this, i)); |
| 47 return alternates; |
| 48 } |
| 49 |
| 41 uint8_t USBInterface::interfaceNumber() const | 50 uint8_t USBInterface::interfaceNumber() const |
| 42 { | 51 { |
| 43 return info().interfaceNumber; | 52 return info().interfaceNumber; |
| 44 } | 53 } |
| 45 | 54 |
| 46 DEFINE_TRACE(USBInterface) | 55 DEFINE_TRACE(USBInterface) |
| 47 { | 56 { |
| 48 visitor->trace(m_configuration); | 57 visitor->trace(m_configuration); |
| 49 } | 58 } |
| 50 | 59 |
| 51 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |