OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_USB_SERVICE_USB_SERVICE_H_ | 5 #ifndef COMPONENTS_USB_SERVICE_USB_SERVICE_H_ |
6 #define COMPONENTS_USB_SERVICE_USB_SERVICE_H_ | 6 #define COMPONENTS_USB_SERVICE_USB_SERVICE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
13 #include "components/usb_service/usb_service_export.h" | 13 #include "components/usb_service/usb_service_export.h" |
14 | 14 |
15 namespace base { | |
16 class SingleThreadTaskRunner; | |
17 } | |
18 | |
15 namespace usb_service { | 19 namespace usb_service { |
16 | 20 |
17 class UsbDevice; | 21 class UsbDevice; |
18 | 22 |
19 // The USB service handles creating and managing an event handler thread that is | 23 // The USB service handles creating and managing an event handler thread that is |
20 // used to manage and dispatch USB events. It is also responsible for device | 24 // used to manage and dispatch USB events. It is also responsible for device |
21 // discovery on the system, which allows it to re-use device handles to prevent | 25 // discovery on the system, which allows it to re-use device handles to prevent |
22 // competition for the same USB device. | 26 // competition for the same USB device. |
23 class USB_SERVICE_EXPORT UsbService : public base::NonThreadSafe { | 27 class USB_SERVICE_EXPORT UsbService : public base::NonThreadSafe { |
24 public: | 28 public: |
25 // Must be called on FILE thread. | 29 // Must be called on a thread with a MessageLoopIO (normally |
Ken Rockot(use gerrit already)
2014/08/28 21:47:03
MessageLoopForIO? I also might omit any mention of
Reilly Grant (use Gerrit)
2014/08/28 22:16:13
I'm using it as an example.
| |
26 // Returns NULL when failed to initialized. | 30 // BrowserThread::FILE). The UI task runner reference is used to talk to the |
27 static UsbService* GetInstance(); | 31 // PermissionBrokerClient on ChromeOS (UI thread). Returns NULL when |
32 // initialization fails. | |
33 static UsbService* GetInstance( | |
34 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | |
28 | 35 |
29 static void SetInstanceForTest(UsbService* instance); | 36 static void SetInstanceForTest(UsbService* instance); |
30 | 37 |
31 virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) = 0; | 38 virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) = 0; |
32 | 39 |
33 // Get all of the devices attached to the system, inserting them into | 40 // Get all of the devices attached to the system, inserting them into |
34 // |devices|. Clears |devices| before use. The result will be sorted by id | 41 // |devices|. Clears |devices| before use. The result will be sorted by id |
35 // in increasing order. Must be called on FILE thread. | 42 // in increasing order. Must be called on FILE thread. |
36 virtual void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices) = 0; | 43 virtual void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices) = 0; |
37 | 44 |
38 protected: | 45 protected: |
39 friend struct base::DefaultDeleter<UsbService>; | 46 friend struct base::DefaultDeleter<UsbService>; |
40 UsbService() {} | 47 UsbService() {} |
41 virtual ~UsbService() {} | 48 virtual ~UsbService() {} |
42 DISALLOW_COPY_AND_ASSIGN(UsbService); | 49 DISALLOW_COPY_AND_ASSIGN(UsbService); |
43 }; | 50 }; |
44 | 51 |
45 } // namespace usb_service | 52 } // namespace usb_service |
46 | 53 |
47 #endif // COMPONENTS_USB_SERVICE_USB_SERVICE_H_ | 54 #endif // COMPONENTS_USB_SERVICE_USB_SERVICE_H_ |
OLD | NEW |