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

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

Issue 1806163002: Track USB alternate interface state in Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink_interface_state
Patch Set: Fixed typo and rebased. Created 4 years, 9 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
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/USBInterface.h" 5 #include "modules/webusb/USBInterface.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "modules/webusb/USBAlternateInterface.h" 8 #include "modules/webusb/USBAlternateInterface.h"
9 #include "modules/webusb/USBConfiguration.h" 9 #include "modules/webusb/USBConfiguration.h"
10 #include "modules/webusb/USBDevice.h" 10 #include "modules/webusb/USBDevice.h"
(...skipping 23 matching lines...) Expand all
34 { 34 {
35 ASSERT(m_configurationIndex < m_device->info().configurations.size()); 35 ASSERT(m_configurationIndex < m_device->info().configurations.size());
36 ASSERT(m_interfaceIndex < m_device->info().configurations[m_configurationInd ex].interfaces.size()); 36 ASSERT(m_interfaceIndex < m_device->info().configurations[m_configurationInd ex].interfaces.size());
37 } 37 }
38 38
39 const WebUSBDeviceInfo::Interface& USBInterface::info() const 39 const WebUSBDeviceInfo::Interface& USBInterface::info() const
40 { 40 {
41 return m_device->info().configurations[m_configurationIndex].interfaces[m_in terfaceIndex]; 41 return m_device->info().configurations[m_configurationIndex].interfaces[m_in terfaceIndex];
42 } 42 }
43 43
44 USBAlternateInterface* USBInterface::alternate() const
45 {
46 if (m_device->isInterfaceClaimed(m_configurationIndex, m_interfaceIndex))
47 return USBAlternateInterface::create(this, m_device->selectedAlternateIn terface(m_interfaceIndex));
48 return nullptr;
49 }
50
44 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const 51 HeapVector<Member<USBAlternateInterface>> USBInterface::alternates() const
45 { 52 {
46 HeapVector<Member<USBAlternateInterface>> alternates; 53 HeapVector<Member<USBAlternateInterface>> alternates;
47 for (size_t i = 0; i < info().alternates.size(); ++i) 54 for (size_t i = 0; i < info().alternates.size(); ++i)
48 alternates.append(USBAlternateInterface::create(this, i)); 55 alternates.append(USBAlternateInterface::create(this, i));
49 return alternates; 56 return alternates;
50 } 57 }
51 58
52 uint8_t USBInterface::interfaceNumber() const 59 uint8_t USBInterface::interfaceNumber() const
53 { 60 {
54 return info().interfaceNumber; 61 return info().interfaceNumber;
55 } 62 }
56 63
57 bool USBInterface::claimed() const 64 bool USBInterface::claimed() const
58 { 65 {
59 return m_device->isInterfaceClaimed(m_configurationIndex, m_interfaceIndex); 66 return m_device->isInterfaceClaimed(m_configurationIndex, m_interfaceIndex);
60 } 67 }
61 68
62 DEFINE_TRACE(USBInterface) 69 DEFINE_TRACE(USBInterface)
63 { 70 {
64 visitor->trace(m_device); 71 visitor->trace(m_device);
65 } 72 }
66 73
67 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webusb/USBInterface.h ('k') | third_party/WebKit/Source/modules/webusb/USBInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698