| 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/USBConfiguration.h" | 5 #include "modules/webusb/USBConfiguration.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "modules/webusb/USBDevice.h" | 8 #include "modules/webusb/USBDevice.h" |
| 9 #include "modules/webusb/USBInterface.h" | 9 #include "modules/webusb/USBInterface.h" |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 USBConfiguration::USBConfiguration(const USBDevice* device, size_t configuration
Index) | 37 USBConfiguration::USBConfiguration(const USBDevice* device, size_t configuration
Index) |
| 38 : m_device(device) | 38 : m_device(device) |
| 39 , m_configurationIndex(configurationIndex) | 39 , m_configurationIndex(configurationIndex) |
| 40 { | 40 { |
| 41 ASSERT(m_device); | 41 ASSERT(m_device); |
| 42 ASSERT(m_configurationIndex < m_device->info().configurations.size()); | 42 ASSERT(m_configurationIndex < m_device->info().configurations.size()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 const USBDevice* USBConfiguration::device() const |
| 46 { |
| 47 return m_device; |
| 48 } |
| 49 |
| 50 size_t USBConfiguration::index() const |
| 51 { |
| 52 return m_configurationIndex; |
| 53 } |
| 54 |
| 45 const WebUSBDeviceInfo::Configuration& USBConfiguration::info() const | 55 const WebUSBDeviceInfo::Configuration& USBConfiguration::info() const |
| 46 { | 56 { |
| 47 return m_device->info().configurations[m_configurationIndex]; | 57 return m_device->info().configurations[m_configurationIndex]; |
| 48 } | 58 } |
| 49 | 59 |
| 50 uint8_t USBConfiguration::configurationValue() const | 60 uint8_t USBConfiguration::configurationValue() const |
| 51 { | 61 { |
| 52 return info().configurationValue; | 62 return info().configurationValue; |
| 53 } | 63 } |
| 54 | 64 |
| 55 String USBConfiguration::configurationName() const | 65 String USBConfiguration::configurationName() const |
| 56 { | 66 { |
| 57 return info().configurationName; | 67 return info().configurationName; |
| 58 } | 68 } |
| 59 | 69 |
| 60 HeapVector<Member<USBInterface>> USBConfiguration::interfaces() const | 70 HeapVector<Member<USBInterface>> USBConfiguration::interfaces() const |
| 61 { | 71 { |
| 62 HeapVector<Member<USBInterface>> interfaces; | 72 HeapVector<Member<USBInterface>> interfaces; |
| 63 for (size_t i = 0; i < info().interfaces.size(); ++i) | 73 for (size_t i = 0; i < info().interfaces.size(); ++i) |
| 64 interfaces.append(USBInterface::create(this, i)); | 74 interfaces.append(USBInterface::create(this, i)); |
| 65 return interfaces; | 75 return interfaces; |
| 66 } | 76 } |
| 67 | 77 |
| 68 DEFINE_TRACE(USBConfiguration) | 78 DEFINE_TRACE(USBConfiguration) |
| 69 { | 79 { |
| 70 visitor->trace(m_device); | 80 visitor->trace(m_device); |
| 71 } | 81 } |
| 72 | 82 |
| 73 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |