Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: Source/modules/webusb/USBInterface.cpp

Issue 1245363002: Add WebUSB bindings and client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cleanup, better error reporting Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ca809010d6ea794823089e06120c130cd48bf33c
--- /dev/null
+++ b/Source/modules/webusb/USBInterface.cpp
@@ -0,0 +1,50 @@
+// 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 "modules/webusb/USBAlternateInterface.h"
+#include "modules/webusb/USBConfiguration.h"
+
+namespace blink {
+
+// static
+USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceIndex)
+{
+ return new USBInterface(configuration, interfaceIndex);
+}
+
+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;
+}
+
+HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const
+{
+ HeapVector<Member<USBAlternateInterface>> alternates;
+ for (size_t i = 0; i < info().alternates.size(); ++i)
+ alternates.append(USBAlternateInterface::create(this, i));
+ return alternates;
+}
+
+DEFINE_TRACE(USBInterface)
+{
+ visitor->trace(m_configuration);
Reilly Grant (use Gerrit) 2015/07/28 22:51:43 #ifdef ENABLE(OILPAN)?
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698