Index: Source/modules/webusb/USBInterface.cpp |
diff --git a/Source/modules/webusb/USBInterface.cpp b/Source/modules/webusb/USBInterface.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..64bb52f46929d83f69dbdcfbae670bb855223341 |
--- /dev/null |
+++ b/Source/modules/webusb/USBInterface.cpp |
@@ -0,0 +1,49 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "modules/webusb/USBInterface.h" |
+ |
+#include "bindings/core/v8/ExceptionState.h" |
+#include "modules/webusb/USBConfiguration.h" |
+ |
+namespace blink { |
+ |
+USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceIndex) |
+{ |
+ return new USBInterface(configuration, interfaceIndex); |
+} |
+ |
+USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceIndex, ExceptionState& exceptionState) |
+{ |
+ 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.
|
+ return new USBInterface(configuration, interfaceIndex); |
+ exceptionState.throwRangeError("Invalid interface index."); |
+ return nullptr; |
+} |
+ |
+USBInterface::USBInterface(const USBConfiguration* configuration, size_t interfaceIndex) |
+ : m_configuration(configuration) |
+ , m_interfaceIndex(interfaceIndex) |
+{ |
+} |
+ |
+const WebUSBDeviceInfo::Interface& USBInterface::info() const |
+{ |
+ const WebUSBDeviceInfo::Configuration& configInfo = m_configuration->info(); |
+ ASSERT(m_interfaceIndex < configInfo.interfaces.size()); |
+ return configInfo.interfaces[m_interfaceIndex]; |
+} |
+ |
+uint8_t USBInterface::interfaceNumber() const |
+{ |
+ return info().interfaceNumber; |
+} |
+ |
+DEFINE_TRACE(USBInterface) |
+{ |
+ visitor->trace(m_configuration); |
+} |
+ |
+} // namespace blink |