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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 virtual void OnDeviceAdded(scoped_refptr<UsbDevice> device); | 42 virtual void OnDeviceAdded(scoped_refptr<UsbDevice> device); |
43 virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device); | 43 virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device); |
44 // For observers that need to process device removal after others have run. | 44 // For observers that need to process device removal after others have run. |
45 // Should not depend on any other service's knowledge of connected devices. | 45 // Should not depend on any other service's knowledge of connected devices. |
46 virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); | 46 virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); |
47 | 47 |
48 // Notifies the observer that the UsbService it depends on is shutting down. | 48 // Notifies the observer that the UsbService it depends on is shutting down. |
49 virtual void WillDestroyUsbService(); | 49 virtual void WillDestroyUsbService(); |
50 }; | 50 }; |
51 | 51 |
52 // The file task runner reference is used for blocking I/O operations. | |
53 // Returns nullptr when initialization fails. | 52 // Returns nullptr when initialization fails. |
54 static std::unique_ptr<UsbService> Create( | 53 static std::unique_ptr<UsbService> Create(); |
55 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); | |
56 | 54 |
57 // Creates a SequencedTaskRunner appropriate for blocking I/O operations. | 55 // Creates a SequencedTaskRunner appropriate for blocking I/O operations. |
58 static scoped_refptr<base::SequencedTaskRunner> CreateBlockingTaskRunner(); | 56 static scoped_refptr<base::SequencedTaskRunner> CreateBlockingTaskRunner(); |
59 | 57 |
60 virtual ~UsbService(); | 58 virtual ~UsbService(); |
61 | 59 |
62 scoped_refptr<UsbDevice> GetDevice(const std::string& guid); | 60 scoped_refptr<UsbDevice> GetDevice(const std::string& guid); |
63 | 61 |
64 // Shuts down the UsbService. Must be called before destroying the UsbService | 62 // Shuts down the UsbService. Must be called before destroying the UsbService |
65 // when tasks can still be posted to the |blocking_task_runner| provided to | 63 // when tasks can still be posted to the |blocking_task_runner| provided to |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 #if DCHECK_IS_ON() | 104 #if DCHECK_IS_ON() |
107 bool did_shutdown_ = false; | 105 bool did_shutdown_ = false; |
108 #endif | 106 #endif |
109 | 107 |
110 DISALLOW_COPY_AND_ASSIGN(UsbService); | 108 DISALLOW_COPY_AND_ASSIGN(UsbService); |
111 }; | 109 }; |
112 | 110 |
113 } // namespace device | 111 } // namespace device |
114 | 112 |
115 #endif // DEVICE_USB_USB_SERVICE_H_ | 113 #endif // DEVICE_USB_USB_SERVICE_H_ |
OLD | NEW |