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 DEVICE_USB_USB_SERVICE_H_ | 5 #ifndef DEVICE_USB_USB_SERVICE_H_ |
6 #define DEVICE_USB_USB_SERVICE_H_ | 6 #define DEVICE_USB_USB_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // These events are delivered from the thread on which the UsbService object | 38 // These events are delivered from the thread on which the UsbService object |
39 // was created. | 39 // was created. |
40 virtual void OnDeviceAdded(scoped_refptr<UsbDevice> device); | 40 virtual void OnDeviceAdded(scoped_refptr<UsbDevice> device); |
41 virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device); | 41 virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device); |
42 // For observers that need to process device removal after others have run. | 42 // For observers that need to process device removal after others have run. |
43 // Should not depend on any other service's knowledge of connected devices. | 43 // Should not depend on any other service's knowledge of connected devices. |
44 virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); | 44 virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); |
45 }; | 45 }; |
46 | 46 |
47 // The file task runner reference is used for blocking I/O operations. | 47 // The file task runner reference is used for blocking I/O operations. |
48 // Returns NULL when initialization fails. | 48 // Returns nullptr when initialization fails. |
49 static UsbService* GetInstance( | 49 static scoped_ptr<UsbService> Create( |
50 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); | 50 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
51 | 51 |
| 52 virtual ~UsbService(); |
| 53 |
52 virtual scoped_refptr<UsbDevice> GetDevice(const std::string& guid) = 0; | 54 virtual scoped_refptr<UsbDevice> GetDevice(const std::string& guid) = 0; |
53 | 55 |
54 // Enumerates available devices. | 56 // Enumerates available devices. |
55 virtual void GetDevices(const GetDevicesCallback& callback) = 0; | 57 virtual void GetDevices(const GetDevicesCallback& callback) = 0; |
56 | 58 |
57 void AddObserver(Observer* observer); | 59 void AddObserver(Observer* observer); |
58 void RemoveObserver(Observer* observer); | 60 void RemoveObserver(Observer* observer); |
59 | 61 |
60 protected: | 62 protected: |
61 UsbService(); | 63 UsbService(); |
62 virtual ~UsbService(); | |
63 | 64 |
64 void NotifyDeviceAdded(scoped_refptr<UsbDevice> device); | 65 void NotifyDeviceAdded(scoped_refptr<UsbDevice> device); |
65 void NotifyDeviceRemoved(scoped_refptr<UsbDevice> device); | 66 void NotifyDeviceRemoved(scoped_refptr<UsbDevice> device); |
66 | 67 |
67 base::ObserverList<Observer, true> observer_list_; | 68 base::ObserverList<Observer, true> observer_list_; |
68 | 69 |
69 private: | 70 private: |
70 friend void base::DeletePointer<UsbService>(UsbService* service); | 71 friend void base::DeletePointer<UsbService>(UsbService* service); |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(UsbService); | 73 DISALLOW_COPY_AND_ASSIGN(UsbService); |
73 }; | 74 }; |
74 | 75 |
75 } // namespace device | 76 } // namespace device |
76 | 77 |
77 #endif // DEVICE_USB_USB_SERVICE_H_ | 78 #endif // DEVICE_USB_USB_SERVICE_H_ |
OLD | NEW |