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/USBEndpoint.h" | 5 #include "modules/webusb/USBEndpoint.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
9 #include "device/usb/public/interfaces/device.mojom-blink.h" | 9 #include "device/usb/public/interfaces/device.mojom-blink.h" |
10 #include "modules/webusb/USBAlternateInterface.h" | 10 #include "modules/webusb/USBAlternateInterface.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 exception_state.ThrowRangeError( | 66 exception_state.ThrowRangeError( |
67 "No such endpoint exists in the given alternate interface."); | 67 "No such endpoint exists in the given alternate interface."); |
68 return nullptr; | 68 return nullptr; |
69 } | 69 } |
70 | 70 |
71 USBEndpoint::USBEndpoint(const USBAlternateInterface* alternate, | 71 USBEndpoint::USBEndpoint(const USBAlternateInterface* alternate, |
72 size_t endpoint_index) | 72 size_t endpoint_index) |
73 : alternate_(alternate), endpoint_index_(endpoint_index) { | 73 : alternate_(alternate), endpoint_index_(endpoint_index) { |
74 DCHECK(alternate_); | 74 DCHECK(alternate_); |
75 ASSERT(endpoint_index_ < alternate_->Info().endpoints.size()); | 75 DCHECK_LT(endpoint_index_, alternate_->Info().endpoints.size()); |
76 } | 76 } |
77 | 77 |
78 const device::mojom::blink::UsbEndpointInfo& USBEndpoint::Info() const { | 78 const device::mojom::blink::UsbEndpointInfo& USBEndpoint::Info() const { |
79 const device::mojom::blink::UsbAlternateInterfaceInfo& alternate_info = | 79 const device::mojom::blink::UsbAlternateInterfaceInfo& alternate_info = |
80 alternate_->Info(); | 80 alternate_->Info(); |
81 ASSERT(endpoint_index_ < alternate_info.endpoints.size()); | 81 DCHECK_LT(endpoint_index_, alternate_info.endpoints.size()); |
82 return *alternate_info.endpoints[endpoint_index_]; | 82 return *alternate_info.endpoints[endpoint_index_]; |
83 } | 83 } |
84 | 84 |
85 String USBEndpoint::direction() const { | 85 String USBEndpoint::direction() const { |
86 return ConvertDirectionToEnum(Info().direction); | 86 return ConvertDirectionToEnum(Info().direction); |
87 } | 87 } |
88 | 88 |
89 String USBEndpoint::type() const { | 89 String USBEndpoint::type() const { |
90 return ConvertTypeToEnum(Info().type); | 90 return ConvertTypeToEnum(Info().type); |
91 } | 91 } |
92 | 92 |
93 DEFINE_TRACE(USBEndpoint) { | 93 DEFINE_TRACE(USBEndpoint) { |
94 visitor->Trace(alternate_); | 94 visitor->Trace(alternate_); |
95 } | 95 } |
96 | 96 |
97 } // namespace blink | 97 } // namespace blink |
OLD | NEW |