OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_USB_USB_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_USB_USB_SERVICE_H_ |
6 #define CHROME_BROWSER_USB_USB_SERVICE_H_ | 6 #define CHROME_BROWSER_USB_USB_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
14 #include "chrome/browser/usb/usb_device.h" | 14 #include "chrome/browser/usb/usb_device.h" |
15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 15 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
16 #include "third_party/libusb/src/libusb/libusb.h" | 16 #include "third_party/libusb/src/libusb/libusb.h" |
17 | 17 |
18 class UsbEventHandler; | 18 class UsbEventHandler; |
19 typedef libusb_context* PlatformUsbContext; | 19 typedef libusb_context* PlatformUsbContext; |
20 | 20 |
21 // The USB service handles creating and managing an event handler thread that is | 21 // The USB service handles creating and managing an event handler thread that is |
22 // used to manage and dispatch USB events. It is also responsbile for device | 22 // used to manage and dispatch USB events. It is also responsbile for device |
23 // discovery on the system, which allows it to re-use device handles to prevent | 23 // discovery on the system, which allows it to re-use device handles to prevent |
24 // competition for the same USB device. | 24 // competition for the same USB device. |
25 class UsbService : public ProfileKeyedService { | 25 class UsbService : public BrowserContextKeyedService { |
26 public: | 26 public: |
27 UsbService(); | 27 UsbService(); |
28 virtual ~UsbService(); | 28 virtual ~UsbService(); |
29 | 29 |
30 // Cleanup must be invoked before the service is destroyed. It interrupts the | 30 // Cleanup must be invoked before the service is destroyed. It interrupts the |
31 // event handling thread and disposes of open devices. | 31 // event handling thread and disposes of open devices. |
32 void Cleanup(); | 32 void Cleanup(); |
33 | 33 |
34 // Find all of the devices attached to the system that are identified by | 34 // Find all of the devices attached to the system that are identified by |
35 // |vendor_id| and |product_id|, inserting them into |devices|. Clears | 35 // |vendor_id| and |product_id|, inserting them into |devices|. Clears |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // The devices_ map contains scoped_refptrs to all open devices, indicated by | 91 // The devices_ map contains scoped_refptrs to all open devices, indicated by |
92 // their vendor and product id. This allows for reusing an open device without | 92 // their vendor and product id. This allows for reusing an open device without |
93 // creating another platform handle for it. | 93 // creating another platform handle for it. |
94 typedef std::map<PlatformUsbDevice, scoped_refptr<UsbDevice> > DeviceMap; | 94 typedef std::map<PlatformUsbDevice, scoped_refptr<UsbDevice> > DeviceMap; |
95 DeviceMap devices_; | 95 DeviceMap devices_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(UsbService); | 97 DISALLOW_COPY_AND_ASSIGN(UsbService); |
98 }; | 98 }; |
99 | 99 |
100 #endif // CHROME_BROWSER_USB_USB_SERVICE_H_ | 100 #endif // CHROME_BROWSER_USB_USB_SERVICE_H_ |
OLD | NEW |