| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 USBDevice* USB::getOrCreateDevice(usb::DeviceInfoPtr deviceInfo) { | 162 USBDevice* USB::getOrCreateDevice(usb::DeviceInfoPtr deviceInfo) { |
| 163 USBDevice* device = m_deviceCache.get(deviceInfo->guid); | 163 USBDevice* device = m_deviceCache.get(deviceInfo->guid); |
| 164 if (!device) { | 164 if (!device) { |
| 165 String guid = deviceInfo->guid; | 165 String guid = deviceInfo->guid; |
| 166 usb::DevicePtr pipe; | 166 usb::DevicePtr pipe; |
| 167 m_deviceManager->GetDevice(guid, mojo::MakeRequest(&pipe)); | 167 m_deviceManager->GetDevice(guid, mojo::MakeRequest(&pipe)); |
| 168 device = USBDevice::create(std::move(deviceInfo), std::move(pipe), | 168 device = USBDevice::create(std::move(deviceInfo), std::move(pipe), |
| 169 getExecutionContext()); | 169 getExecutionContext()); |
| 170 m_deviceCache.add(guid, device); | 170 m_deviceCache.insert(guid, device); |
| 171 } | 171 } |
| 172 return device; | 172 return device; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void USB::onGetDevices(ScriptPromiseResolver* resolver, | 175 void USB::onGetDevices(ScriptPromiseResolver* resolver, |
| 176 Vector<usb::DeviceInfoPtr> deviceInfos) { | 176 Vector<usb::DeviceInfoPtr> deviceInfos) { |
| 177 auto requestEntry = m_deviceManagerRequests.find(resolver); | 177 auto requestEntry = m_deviceManagerRequests.find(resolver); |
| 178 if (requestEntry == m_deviceManagerRequests.end()) | 178 if (requestEntry == m_deviceManagerRequests.end()) |
| 179 return; | 179 return; |
| 180 m_deviceManagerRequests.remove(requestEntry); | 180 m_deviceManagerRequests.remove(requestEntry); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 DEFINE_TRACE(USB) { | 240 DEFINE_TRACE(USB) { |
| 241 visitor->trace(m_deviceManagerRequests); | 241 visitor->trace(m_deviceManagerRequests); |
| 242 visitor->trace(m_chooserServiceRequests); | 242 visitor->trace(m_chooserServiceRequests); |
| 243 visitor->trace(m_deviceCache); | 243 visitor->trace(m_deviceCache); |
| 244 EventTargetWithInlineData::trace(visitor); | 244 EventTargetWithInlineData::trace(visitor); |
| 245 ContextLifecycleObserver::trace(visitor); | 245 ContextLifecycleObserver::trace(visitor); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace blink | 248 } // namespace blink |
| OLD | NEW |