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

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: Don't attempt to signal an error on a closed connection. 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 resolver->resolve(devices); 158 resolver->resolve(devices);
159 m_deviceManagerRequests.remove(resolver); 159 m_deviceManagerRequests.remove(resolver);
160 } 160 }
161 161
162 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de viceInfo) 162 void USB::onGetPermission(ScriptPromiseResolver* resolver, usb::DeviceInfoPtr de viceInfo)
163 { 163 {
164 if (!isActive(resolver)) 164 if (!isActive(resolver))
165 return; 165 return;
166 166
167 if (!m_deviceManager) {
haraken 2016/05/04 03:26:15 Does this mean that USB::onGetPermission can be ca
Reilly Grant (use Gerrit) 2016/05/04 18:20:41 No, the issue is that m_deviceManager and m_choose
168 resolver->reject(DOMException::create(NotFoundError, kNoServiceError));
169 return;
170 }
171
167 if (deviceInfo) { 172 if (deviceInfo) {
168 usb::DevicePtr device; 173 usb::DevicePtr device;
169 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device)); 174 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device));
170 resolver->resolve(USBDevice::create(std::move(deviceInfo), std::move(dev ice), resolver->getExecutionContext())); 175 resolver->resolve(USBDevice::create(std::move(deviceInfo), std::move(dev ice), resolver->getExecutionContext()));
171 } else { 176 } else {
172 resolver->reject(DOMException::create(NotFoundError, "No device selected .")); 177 resolver->reject(DOMException::create(NotFoundError, "No device selected ."));
173 } 178 }
174 } 179 }
175 180
176 void USB::onDeviceChanges(usb::DeviceChangeNotificationPtr notification) 181 void USB::onDeviceChanges(usb::DeviceChangeNotificationPtr notification)
177 { 182 {
178 m_deviceManager->GetDeviceChanges(createBaseCallback(bind<usb::DeviceChangeN otificationPtr>(&USB::onDeviceChanges, WeakPersistentThisPointer<USB>(this)))); 183 m_deviceManager->GetDeviceChanges(createBaseCallback(bind<usb::DeviceChangeN otificationPtr>(&USB::onDeviceChanges, WeakPersistentThisPointer<USB>(this))));
haraken 2016/05/04 03:26:15 I'm wondering why you don't need the if(!m_deviceM
Reilly Grant (use Gerrit) 2016/05/04 18:22:32 Since this method is called to handle a message ar
179 for (auto& deviceInfo : notification->devices_added.PassStorage()) { 184 for (auto& deviceInfo : notification->devices_added.PassStorage()) {
180 usb::DevicePtr device; 185 usb::DevicePtr device;
181 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device)); 186 m_deviceManager->GetDevice(deviceInfo->guid, mojo::GetProxy(&device));
182 dispatchEvent(USBConnectionEvent::create(EventTypeNames::connect, USBDev ice::create(std::move(deviceInfo), std::move(device), getExecutionContext()))); 187 dispatchEvent(USBConnectionEvent::create(EventTypeNames::connect, USBDev ice::create(std::move(deviceInfo), std::move(device), getExecutionContext())));
183 } 188 }
184 for (auto& deviceInfo : notification->devices_removed.PassStorage()) 189 for (auto& deviceInfo : notification->devices_removed.PassStorage())
185 dispatchEvent(USBConnectionEvent::create(EventTypeNames::disconnect, USB Device::create(std::move(deviceInfo), nullptr, getExecutionContext()))); 190 dispatchEvent(USBConnectionEvent::create(EventTypeNames::disconnect, USB Device::create(std::move(deviceInfo), nullptr, getExecutionContext())));
186 } 191 }
187 192
188 void USB::onDeviceManagerConnectionError() 193 void USB::onDeviceManagerConnectionError()
(...skipping 18 matching lines...) Expand all
207 212
208 DEFINE_TRACE(USB) 213 DEFINE_TRACE(USB)
209 { 214 {
210 EventTargetWithInlineData::trace(visitor); 215 EventTargetWithInlineData::trace(visitor);
211 ContextLifecycleObserver::trace(visitor); 216 ContextLifecycleObserver::trace(visitor);
212 visitor->trace(m_deviceManagerRequests); 217 visitor->trace(m_deviceManagerRequests);
213 visitor->trace(m_chooserServiceRequests); 218 visitor->trace(m_chooserServiceRequests);
214 } 219 }
215 220
216 } // namespace blink 221 } // 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