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/USBInterface.h" | |
7 | |
8 #include "bindings/core/v8/ExceptionState.h" | |
9 #include "modules/webusb/USBConfiguration.h" | |
10 | |
11 namespace blink { | |
12 | |
13 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceIndex) | |
14 { | |
15 return new USBInterface(configuration, interfaceIndex); | |
16 } | |
17 | |
18 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceIndex, ExceptionState& exceptionState) | |
19 { | |
20 if (interfaceIndex < configuration->info().interfaces.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.
| |
21 return new USBInterface(configuration, interfaceIndex); | |
22 exceptionState.throwRangeError("Invalid interface index."); | |
23 return nullptr; | |
24 } | |
25 | |
26 USBInterface::USBInterface(const USBConfiguration* configuration, size_t interfa ceIndex) | |
27 : m_configuration(configuration) | |
28 , m_interfaceIndex(interfaceIndex) | |
29 { | |
30 } | |
31 | |
32 const WebUSBDeviceInfo::Interface& USBInterface::info() const | |
33 { | |
34 const WebUSBDeviceInfo::Configuration& configInfo = m_configuration->info(); | |
35 ASSERT(m_interfaceIndex < configInfo.interfaces.size()); | |
36 return configInfo.interfaces[m_interfaceIndex]; | |
37 } | |
38 | |
39 uint8_t USBInterface::interfaceNumber() const | |
40 { | |
41 return info().interfaceNumber; | |
42 } | |
43 | |
44 DEFINE_TRACE(USBInterface) | |
45 { | |
46 visitor->trace(m_configuration); | |
47 } | |
48 | |
49 } // namespace blink | |
OLD | NEW |