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/USBAlternateInterface.h" | |
| 7 | |
| 8 #include "modules/webusb/USBEndpoint.h" | |
| 9 #include "modules/webusb/USBInterface.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 // static | |
| 14 USBAlternateInterface* USBAlternateInterface::create(const USBInterface* interfa ce, size_t alternateIndex) | |
| 15 { | |
| 16 return new USBAlternateInterface(interface, alternateIndex); | |
| 17 } | |
| 18 | |
| 19 USBAlternateInterface::USBAlternateInterface(const USBInterface* interface, size _t alternateIndex) | |
| 20 : m_interface(interface) | |
| 21 , m_alternateIndex(alternateIndex) | |
| 22 { | |
| 23 } | |
| 24 | |
| 25 const WebUSBDeviceInfo::AlternateInterface& USBAlternateInterface::info() const | |
| 26 { | |
| 27 const WebUSBDeviceInfo::Interface& interfaceInfo = m_interface->info(); | |
| 28 ASSERT(m_alternateIndex < interfaceInfo.alternates.size()); | |
| 29 return interfaceInfo.alternates[m_alternateIndex]; | |
| 30 } | |
| 31 | |
| 32 uint8_t USBAlternateInterface::alternateSetting() const | |
| 33 { | |
| 34 return info().alternateSetting; | |
| 35 } | |
| 36 | |
| 37 uint8_t USBAlternateInterface::interfaceClass() const | |
| 38 { | |
| 39 return info().classCode; | |
| 40 } | |
| 41 | |
| 42 uint8_t USBAlternateInterface::interfaceSubclass() const | |
| 43 { | |
| 44 return info().subclassCode; | |
| 45 } | |
| 46 | |
| 47 uint8_t USBAlternateInterface::interfaceProtocol() const | |
| 48 { | |
| 49 return info().protocolCode; | |
| 50 } | |
| 51 | |
| 52 String USBAlternateInterface::interfaceName() const | |
| 53 { | |
| 54 return info().interfaceName; | |
| 55 } | |
| 56 | |
| 57 HeapVector<Member<USBEndpoint>> USBAlternateInterface::endpoints() const | |
| 58 { | |
| 59 HeapVector<Member<USBEndpoint>> endpoints; | |
| 60 for (size_t i = 0; i < info().endpoints.size(); ++i) | |
| 61 endpoints.append(USBEndpoint::create(this, i)); | |
| 62 return endpoints; | |
| 63 } | |
| 64 | |
| 65 DEFINE_TRACE(USBAlternateInterface) | |
| 66 { | |
| 67 visitor->trace(m_interface); | |
|
Reilly Grant (use Gerrit)
2015/07/28 22:51:42
#ifdef ENABLE(OILPAN)?
Ken Rockot(use gerrit already)
2015/07/28 23:21:39
Nah. Only necessary in cases where you're tracing
| |
| 68 } | |
| 69 | |
| 70 } // namespace blink | |
| OLD | NEW |