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

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

Issue 1951723002: Use the Mojo StubBindings interface correctly in WebUSB LayoutTests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 7 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 | « third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 m_deviceManagerRequests.remove(resolver); 155 m_deviceManagerRequests.remove(resolver);
156 } 156 }
157 157
158 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de viceInfo) 158 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de viceInfo)
159 { 159 {
160 auto requestEntry = m_chooserServiceRequests.find(resolver); 160 auto requestEntry = m_chooserServiceRequests.find(resolver);
161 if (requestEntry == m_chooserServiceRequests.end()) 161 if (requestEntry == m_chooserServiceRequests.end())
162 return; 162 return;
163 m_chooserServiceRequests.remove(requestEntry); 163 m_chooserServiceRequests.remove(requestEntry);
164 164
165 if (!m_deviceManager) {
166 resolver->reject(DOMException::create(NotFoundError, kNoServiceError));
167 return;
168 }
169
165 if (deviceInfo) { 170 if (deviceInfo) {
166 usb::DevicePtr device; 171 usb::DevicePtr device;
167 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device)); 172 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device));
168 resolver->resolve(USBDevice::create(std::move(deviceInfo), std::move(dev ice), resolver->getExecutionContext())); 173 resolver->resolve(USBDevice::create(std::move(deviceInfo), std::move(dev ice), resolver->getExecutionContext()));
169 } else { 174 } else {
170 resolver->reject(DOMException::create(NotFoundError, "No device selected .")); 175 resolver->reject(DOMException::create(NotFoundError, "No device selected ."));
171 } 176 }
172 } 177 }
173 178
174 void USB::onDeviceChanges(usb::DeviceChangeNotificationPtr notification) 179 void USB::onDeviceChanges(usb::DeviceChangeNotificationPtr notification)
(...skipping 26 matching lines...) Expand all
201 206
202 DEFINE_TRACE(USB) 207 DEFINE_TRACE(USB)
203 { 208 {
204 EventTargetWithInlineData::trace(visitor); 209 EventTargetWithInlineData::trace(visitor);
205 ContextLifecycleObserver::trace(visitor); 210 ContextLifecycleObserver::trace(visitor);
206 visitor->trace(m_deviceManagerRequests); 211 visitor->trace(m_deviceManagerRequests);
207 visitor->trace(m_chooserServiceRequests); 212 visitor->trace(m_chooserServiceRequests);
208 } 213 }
209 214
210 } // namespace blink 215 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698