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" |
11 #include "chrome/browser/usb/usb_device_handle.h" | 11 #include "chrome/browser/usb/usb_device_handle.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "third_party/libusb/src/libusb/libusb.h" | 13 #include "third_party/libusb/src/libusb/libusb.h" |
14 | 14 |
15 using content::BrowserThread; | 15 using content::BrowserThread; |
16 | 16 |
17 UsbDevice::UsbDevice( | 17 UsbDevice::UsbDevice( |
18 scoped_refptr<UsbContext> context, | 18 scoped_refptr<UsbContext> context, |
19 PlatformUsbDevice platform_device, | 19 PlatformUsbDevice platform_device, |
20 uint16 vendor_id, | 20 uint16 vendor_id, |
21 uint16 product_id) | 21 uint16 product_id, |
| 22 uint32 unique_id) |
22 : platform_device_(platform_device), | 23 : platform_device_(platform_device), |
23 vendor_id_(vendor_id), | 24 vendor_id_(vendor_id), |
24 product_id_(product_id), | 25 product_id_(product_id), |
| 26 unique_id_(unique_id), |
25 context_(context) { | 27 context_(context) { |
26 CHECK(platform_device) << "platform_device cannot be NULL"; | 28 CHECK(platform_device) << "platform_device cannot be NULL"; |
27 libusb_ref_device(platform_device); | 29 libusb_ref_device(platform_device); |
28 } | 30 } |
29 | 31 |
30 UsbDevice::UsbDevice() | 32 UsbDevice::UsbDevice() |
31 : platform_device_(NULL), | 33 : platform_device_(NULL), |
32 vendor_id_(0), | 34 vendor_id_(0), |
33 product_id_(0), | 35 product_id_(0), |
| 36 unique_id_(0), |
34 context_(NULL) { | 37 context_(NULL) { |
35 } | 38 } |
36 | 39 |
37 UsbDevice::~UsbDevice() { | 40 UsbDevice::~UsbDevice() { |
38 DCHECK(thread_checker_.CalledOnValidThread()); | 41 DCHECK(thread_checker_.CalledOnValidThread()); |
39 for (HandlesVector::iterator it = handles_.begin(); | 42 for (HandlesVector::iterator it = handles_.begin(); |
40 it != handles_.end(); | 43 it != handles_.end(); |
41 ++it) { | 44 ++it) { |
42 (*it)->InternalClose(); | 45 (*it)->InternalClose(); |
43 } | 46 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 DCHECK(thread_checker_.CalledOnValidThread()); | 95 DCHECK(thread_checker_.CalledOnValidThread()); |
93 HandlesVector handles; | 96 HandlesVector handles; |
94 swap(handles, handles_); | 97 swap(handles, handles_); |
95 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = | 98 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = |
96 handles.begin(); | 99 handles.begin(); |
97 it != handles.end(); | 100 it != handles.end(); |
98 ++it) { | 101 ++it) { |
99 (*it)->InternalClose(); | 102 (*it)->InternalClose(); |
100 } | 103 } |
101 } | 104 } |
OLD | NEW |