Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "modules/webusb/USBConfiguration.h" | |
| 7 | |
| 8 #include "bindings/core/v8/ExceptionState.h" | |
| 9 #include "modules/webusb/USBDevice.h" | |
| 10 #include "modules/webusb/USBInterface.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 USBConfiguration* USBConfiguration::create(const USBDevice* device, size_t confi gurationIndex) | |
| 15 { | |
| 16 return new USBConfiguration(device, configurationIndex); | |
| 17 } | |
| 18 | |
| 19 USBConfiguration* USBConfiguration::create(const USBDevice* device, size_t confi gurationIndex, ExceptionState& exceptionState) | |
| 20 { | |
| 21 if (configurationIndex < device->info().configurations.size()) | |
|
Reilly Grant (use Gerrit)
2015/08/03 23:00:50
Since this constructor will be called from scripts
Ken Rockot(use gerrit already)
2015/08/04 00:51:25
Done.
| |
| 22 return new USBConfiguration(device, configurationIndex); | |
| 23 exceptionState.throwRangeError("Invalid configuration index."); | |
| 24 return nullptr; | |
| 25 } | |
| 26 | |
| 27 USBConfiguration::USBConfiguration(const USBDevice* device, size_t configuration Index) | |
| 28 : m_device(device) | |
| 29 , m_configurationIndex(configurationIndex) | |
| 30 { | |
| 31 } | |
| 32 | |
| 33 const WebUSBDeviceInfo::Configuration& USBConfiguration::info() const | |
| 34 { | |
| 35 const WebUSBDeviceInfo& deviceInfo = m_device->info(); | |
| 36 ASSERT(m_configurationIndex < deviceInfo.configurations.size()); | |
| 37 return deviceInfo.configurations[m_configurationIndex]; | |
| 38 } | |
| 39 | |
| 40 uint8_t USBConfiguration::configurationValue() const | |
| 41 { | |
| 42 return info().configurationValue; | |
| 43 } | |
| 44 | |
| 45 String USBConfiguration::configurationName() const | |
| 46 { | |
| 47 return info().configurationName; | |
| 48 } | |
| 49 | |
| 50 HeapVector<Member<USBInterface>> USBConfiguration::interfaces() const | |
| 51 { | |
| 52 HeapVector<Member<USBInterface>> interfaces; | |
| 53 for (size_t i = 0; i < info().interfaces.size(); ++i) | |
| 54 interfaces.append(USBInterface::create(this, i)); | |
| 55 return interfaces; | |
| 56 } | |
| 57 | |
| 58 DEFINE_TRACE(USBConfiguration) | |
| 59 { | |
| 60 visitor->trace(m_device); | |
| 61 } | |
| 62 | |
| 63 } // namespace blink | |
| OLD | NEW |