| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/usb/usb_device.h" | 5 #include "chrome/browser/usb/usb_device.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/usb/usb_context.h" | 10 #include "chrome/browser/usb/usb_context.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 STLClearObject(&handles_); | 44 STLClearObject(&handles_); |
| 45 libusb_unref_device(platform_device_); | 45 libusb_unref_device(platform_device_); |
| 46 } | 46 } |
| 47 | 47 |
| 48 scoped_refptr<UsbDeviceHandle> UsbDevice::Open() { | 48 scoped_refptr<UsbDeviceHandle> UsbDevice::Open() { |
| 49 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 PlatformUsbDeviceHandle handle; | 50 PlatformUsbDeviceHandle handle; |
| 51 int rv = libusb_open(platform_device_, &handle); | 51 int rv = libusb_open(platform_device_, &handle); |
| 52 if (LIBUSB_SUCCESS == rv) { | 52 if (LIBUSB_SUCCESS == rv) { |
| 53 scoped_refptr<UsbDeviceHandle> device_handle = | 53 scoped_refptr<UsbDeviceHandle> device_handle = |
| 54 new UsbDeviceHandle(this, handle); | 54 new UsbDeviceHandle(context_, this, handle); |
| 55 handles_.push_back(device_handle); | 55 handles_.push_back(device_handle); |
| 56 return device_handle; | 56 return device_handle; |
| 57 } | 57 } |
| 58 return NULL; | 58 return NULL; |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool UsbDevice::Close(scoped_refptr<UsbDeviceHandle> handle) { | 61 bool UsbDevice::Close(scoped_refptr<UsbDeviceHandle> handle) { |
| 62 DCHECK(thread_checker_.CalledOnValidThread()); | 62 DCHECK(thread_checker_.CalledOnValidThread()); |
| 63 | 63 |
| 64 for (HandlesVector::iterator it = handles_.begin(); | 64 for (HandlesVector::iterator it = handles_.begin(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 89 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 HandlesVector handles; | 90 HandlesVector handles; |
| 91 swap(handles, handles_); | 91 swap(handles, handles_); |
| 92 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = | 92 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = |
| 93 handles.begin(); | 93 handles.begin(); |
| 94 it != handles.end(); | 94 it != handles.end(); |
| 95 ++it) { | 95 ++it) { |
| 96 (*it)->InternalClose(); | 96 (*it)->InternalClose(); |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |