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

Side by Side Diff: content/renderer/usb/web_usb_device_impl.cc

Issue 1755683004: Skip attempting to bind a DevicePtr for a removed device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 "content/renderer/usb/web_usb_device_impl.h" 5 #include "content/renderer/usb/web_usb_device_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 scoped_callbacks->onSuccess(adoptWebPtr(info.release())); 228 scoped_callbacks->onSuccess(adoptWebPtr(info.release()));
229 } 229 }
230 230
231 } // namespace 231 } // namespace
232 232
233 WebUSBDeviceImpl::WebUSBDeviceImpl(device::usb::DevicePtr device, 233 WebUSBDeviceImpl::WebUSBDeviceImpl(device::usb::DevicePtr device,
234 const blink::WebUSBDeviceInfo& device_info) 234 const blink::WebUSBDeviceInfo& device_info)
235 : device_(std::move(device)), 235 : device_(std::move(device)),
236 device_info_(device_info), 236 device_info_(device_info),
237 weak_factory_(this) { 237 weak_factory_(this) {
238 device_.set_connection_error_handler([this]() { device_.reset(); }); 238 if (device_)
239 device_.set_connection_error_handler([this]() { device_.reset(); });
239 } 240 }
240 241
241 WebUSBDeviceImpl::~WebUSBDeviceImpl() {} 242 WebUSBDeviceImpl::~WebUSBDeviceImpl() {}
242 243
243 const blink::WebUSBDeviceInfo& WebUSBDeviceImpl::info() const { 244 const blink::WebUSBDeviceInfo& WebUSBDeviceImpl::info() const {
244 return device_info_; 245 return device_info_;
245 } 246 }
246 247
247 void WebUSBDeviceImpl::open(blink::WebUSBDeviceOpenCallbacks* callbacks) { 248 void WebUSBDeviceImpl::open(blink::WebUSBDeviceOpenCallbacks* callbacks) {
248 auto scoped_callbacks = MakeScopedUSBCallbacks(callbacks); 249 auto scoped_callbacks = MakeScopedUSBCallbacks(callbacks);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 430
430 void WebUSBDeviceImpl::reset(blink::WebUSBDeviceResetCallbacks* callbacks) { 431 void WebUSBDeviceImpl::reset(blink::WebUSBDeviceResetCallbacks* callbacks) {
431 auto scoped_callbacks = MakeScopedUSBCallbacks(callbacks); 432 auto scoped_callbacks = MakeScopedUSBCallbacks(callbacks);
432 if (device_) 433 if (device_)
433 device_->Reset(base::Bind(&HandlePassFailDeviceOperation, 434 device_->Reset(base::Bind(&HandlePassFailDeviceOperation,
434 base::Passed(&scoped_callbacks), 435 base::Passed(&scoped_callbacks),
435 kDeviceResetFailed)); 436 kDeviceResetFailed));
436 } 437 }
437 438
438 } // namespace content 439 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/usb/web_usb_client_impl.cc ('k') | third_party/WebKit/LayoutTests/usb/usb.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698