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

Side by Side Diff: Source/modules/webusb/USBInterface.cpp

Issue 1252913014: WebUSB bindings part 3 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update expeced interface listing Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « Source/modules/webusb/USBInterface.h ('k') | Source/modules/webusb/USBInterface.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/USBInterface.h"
7
8 #include "bindings/core/v8/ExceptionState.h"
9 #include "modules/webusb/USBConfiguration.h"
10
11 namespace blink {
12
13 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceIndex)
14 {
15 return new USBInterface(configuration, interfaceIndex);
16 }
17
18 USBInterface* USBInterface::create(const USBConfiguration* configuration, size_t interfaceNumber, ExceptionState& exceptionState)
19 {
20 for (size_t i = 0; i < configuration->info().interfaces.size(); ++i) {
21 if (configuration->info().interfaces[i].interfaceNumber == interfaceNumb er)
22 return new USBInterface(configuration, i);
23 }
24 exceptionState.throwRangeError("Invalid interface index.");
25 return nullptr;
26 }
27
28 USBInterface::USBInterface(const USBConfiguration* configuration, size_t interfa ceIndex)
29 : m_configuration(configuration)
30 , m_interfaceIndex(interfaceIndex)
31 {
32 ASSERT(m_configuration);
33 ASSERT(m_interfaceIndex < m_configuration->info().interfaces.size());
34 }
35
36 const WebUSBDeviceInfo::Interface& USBInterface::info() const
37 {
38 return m_configuration->info().interfaces[m_interfaceIndex];
39 }
40
41 uint8_t USBInterface::interfaceNumber() const
42 {
43 return info().interfaceNumber;
44 }
45
46 DEFINE_TRACE(USBInterface)
47 {
48 visitor->trace(m_configuration);
49 }
50
51 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webusb/USBInterface.h ('k') | Source/modules/webusb/USBInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698