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

Unified Diff: device/usb/mojo/device_impl.cc

Issue 1693433003: webusb: Reject the promise if the device is already open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/usb/web_usb_device_impl.cc ('k') | device/usb/mojo/device_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/mojo/device_impl.cc
diff --git a/device/usb/mojo/device_impl.cc b/device/usb/mojo/device_impl.cc
index 724e911d2977df81160944290c65ba18c2056bb5..0d1c64f6a2dd1336fe8b659ce9407633af9dbdf7 100644
--- a/device/usb/mojo/device_impl.cc
+++ b/device/usb/mojo/device_impl.cc
@@ -251,8 +251,11 @@ void DeviceImpl::GetConfiguration(const GetConfigurationCallback& callback) {
}
void DeviceImpl::Open(const OpenCallback& callback) {
- device_->Open(
- base::Bind(&DeviceImpl::OnOpen, weak_factory_.GetWeakPtr(), callback));
+ if (device_handle_)
+ callback.Run(OpenDeviceError::ALREADY_OPEN);
+ else
+ device_->Open(
+ base::Bind(&DeviceImpl::OnOpen, weak_factory_.GetWeakPtr(), callback));
}
void DeviceImpl::Close(const CloseCallback& callback) {
« no previous file with comments | « content/renderer/usb/web_usb_device_impl.cc ('k') | device/usb/mojo/device_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698