| OLD | NEW |
| 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/USB.h" | 5 #include "modules/webusb/USB.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (!device) { | 151 if (!device) { |
| 152 String guid = deviceInfo->guid; | 152 String guid = deviceInfo->guid; |
| 153 usb::DevicePtr pipe; | 153 usb::DevicePtr pipe; |
| 154 m_deviceManager->GetDevice(guid, mojo::GetProxy(&pipe)); | 154 m_deviceManager->GetDevice(guid, mojo::GetProxy(&pipe)); |
| 155 device = USBDevice::create(std::move(deviceInfo), std::move(pipe), getEx
ecutionContext()); | 155 device = USBDevice::create(std::move(deviceInfo), std::move(pipe), getEx
ecutionContext()); |
| 156 m_deviceCache.add(guid, device); | 156 m_deviceCache.add(guid, device); |
| 157 } | 157 } |
| 158 return device; | 158 return device; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void USB::onGetDevices(ScriptPromiseResolver* resolver, mojo::WTFArray<usb::Devi
ceInfoPtr> deviceInfos) | 161 void USB::onGetDevices(ScriptPromiseResolver* resolver, Vector<usb::DeviceInfoPt
r> deviceInfos) |
| 162 { | 162 { |
| 163 auto requestEntry = m_deviceManagerRequests.find(resolver); | 163 auto requestEntry = m_deviceManagerRequests.find(resolver); |
| 164 if (requestEntry == m_deviceManagerRequests.end()) | 164 if (requestEntry == m_deviceManagerRequests.end()) |
| 165 return; | 165 return; |
| 166 m_deviceManagerRequests.remove(requestEntry); | 166 m_deviceManagerRequests.remove(requestEntry); |
| 167 | 167 |
| 168 HeapVector<Member<USBDevice>> devices; | 168 HeapVector<Member<USBDevice>> devices; |
| 169 for (auto& deviceInfo : deviceInfos.PassStorage()) | 169 for (auto& deviceInfo : deviceInfos) |
| 170 devices.append(getOrCreateDevice(std::move(deviceInfo))); | 170 devices.append(getOrCreateDevice(std::move(deviceInfo))); |
| 171 resolver->resolve(devices); | 171 resolver->resolve(devices); |
| 172 m_deviceManagerRequests.remove(resolver); | 172 m_deviceManagerRequests.remove(resolver); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de
viceInfo) | 175 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de
viceInfo) |
| 176 { | 176 { |
| 177 auto requestEntry = m_chooserServiceRequests.find(resolver); | 177 auto requestEntry = m_chooserServiceRequests.find(resolver); |
| 178 if (requestEntry == m_chooserServiceRequests.end()) | 178 if (requestEntry == m_chooserServiceRequests.end()) |
| 179 return; | 179 return; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 DEFINE_TRACE(USB) | 227 DEFINE_TRACE(USB) |
| 228 { | 228 { |
| 229 EventTargetWithInlineData::trace(visitor); | 229 EventTargetWithInlineData::trace(visitor); |
| 230 ContextLifecycleObserver::trace(visitor); | 230 ContextLifecycleObserver::trace(visitor); |
| 231 visitor->trace(m_deviceManagerRequests); | 231 visitor->trace(m_deviceManagerRequests); |
| 232 visitor->trace(m_chooserServiceRequests); | 232 visitor->trace(m_chooserServiceRequests); |
| 233 visitor->trace(m_deviceCache); | 233 visitor->trace(m_deviceCache); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace blink | 236 } // namespace blink |
| OLD | NEW |