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/USBEndpoint.h" | |
| 7 | |
| 8 #include "modules/webusb/USBAlternateInterface.h" | |
| 9 #include "public/platform/modules/webusb/WebUSBDevice.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 String convertDirection(const WebUSBDevice::TransferDirection& direction) | |
| 16 { | |
| 17 switch (direction) { | |
| 18 case WebUSBDevice::TransferDirectionIn: | |
| 19 return "in"; | |
| 20 case WebUSBDevice::TransferDirectionOut: | |
| 21 return "out"; | |
| 22 default: | |
| 23 ASSERT_NOT_REACHED(); | |
| 24 return ""; | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 String convertType(const WebUSBDeviceInfo::Endpoint::Type& type) | |
| 29 { | |
| 30 switch (type) { | |
| 31 case WebUSBDeviceInfo::Endpoint::TypeBulk: | |
| 32 return "bulk"; | |
| 33 case WebUSBDeviceInfo::Endpoint::TypeInterrupt: | |
| 34 return "interrupt"; | |
| 35 case WebUSBDeviceInfo::Endpoint::TypeIsochronous: | |
| 36 return "isochronous"; | |
| 37 default: | |
| 38 ASSERT_NOT_REACHED(); | |
| 39 return ""; | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 } // namespace | |
| 44 | |
| 45 // static | |
| 46 USBEndpoint* USBEndpoint::create(const USBAlternateInterface* alternate, size_t endpointIndex) | |
| 47 { | |
| 48 return new USBEndpoint(alternate, endpointIndex); | |
| 49 } | |
| 50 | |
| 51 USBEndpoint::USBEndpoint(const USBAlternateInterface* alternate, size_t endpoint Index) | |
| 52 : m_alternate(alternate) | |
| 53 , m_endpointIndex(endpointIndex) | |
| 54 { | |
| 55 } | |
| 56 | |
| 57 const WebUSBDeviceInfo::Endpoint& USBEndpoint::info() const | |
| 58 { | |
| 59 const WebUSBDeviceInfo::AlternateInterface& alternateInfo = m_alternate->inf o(); | |
| 60 ASSERT(m_endpointIndex < alternateInfo.endpoints.size()); | |
| 61 return alternateInfo.endpoints[m_endpointIndex]; | |
| 62 } | |
| 63 | |
| 64 uint8_t USBEndpoint::endpointNumber() const | |
| 65 { | |
| 66 return info().endpointNumber; | |
| 67 } | |
| 68 | |
| 69 String USBEndpoint::direction() const | |
| 70 { | |
| 71 return convertDirection(info().direction); | |
| 72 } | |
| 73 | |
| 74 String USBEndpoint::type() const | |
| 75 { | |
| 76 return convertType(info().type); | |
| 77 } | |
| 78 | |
| 79 unsigned USBEndpoint::packetSize() const | |
| 80 { | |
| 81 return info().packetSize; | |
| 82 } | |
| 83 | |
| 84 DEFINE_TRACE(USBEndpoint) | |
| 85 { | |
| 86 visitor->trace(m_alternate); | |
|
Reilly Grant (use Gerrit)
2015/07/28 22:51:43
#ifdef ENABLE(OILPAN)?
| |
| 87 } | |
| 88 | |
| 89 } // namespace blink | |
| OLD | NEW |