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

Side by Side Diff: Source/modules/webusb/USBConfiguration.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, 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
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/USBConfiguration.h"
7
8 #include "modules/webusb/USBDevice.h"
9 #include "modules/webusb/USBInterface.h"
10
11 namespace blink {
12
13 // static
14 USBConfiguration* USBConfiguration::create(const USBDevice* device, size_t confi gurationIndex)
15 {
16 return new USBConfiguration(device, configurationIndex);
17 }
18
19 USBConfiguration::USBConfiguration(const USBDevice* device, size_t configuration Index)
20 : m_device(device)
21 , m_configurationIndex(configurationIndex)
22 {
23 }
24
25 const WebUSBDeviceInfo::Configuration& USBConfiguration::info() const
26 {
27 const WebUSBDeviceInfo& deviceInfo = m_device->info();
28 ASSERT(m_configurationIndex < deviceInfo.configurations.size());
29 return deviceInfo.configurations[m_configurationIndex];
30 }
31
32 uint8_t USBConfiguration::configurationValue() const
33 {
34 return info().configurationValue;
35 }
36
37 String USBConfiguration::configurationName() const
38 {
39 return info().configurationName;
40 }
41
42 HeapVector<Member<USBInterface>> USBConfiguration::interfaces() const
43 {
44 HeapVector<Member<USBInterface>> interfaces;
45 for (size_t i = 0; i < info().interfaces.size(); ++i)
46 interfaces.append(USBInterface::create(this, i));
47 return interfaces;
48 }
49
50 DEFINE_TRACE(USBConfiguration)
51 {
52 visitor->trace(m_device);
Reilly Grant (use Gerrit) 2015/07/28 22:51:42 #ifdef ENABLE(OILPAN)?
53 }
54
55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698