| 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 <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace device { | 22 namespace device { |
| 23 | 23 |
| 24 class UsbDevice; | 24 class UsbDevice; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 // For observers that need to process device removal after others have run. | 43 // For observers that need to process device removal after others have run. |
| 44 // Should not depend on any other service's knowledge of connected devices. | 44 // Should not depend on any other service's knowledge of connected devices. |
| 45 virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); | 45 virtual void OnDeviceRemovedCleanup(scoped_refptr<UsbDevice> device); |
| 46 | 46 |
| 47 // Notifies the observer that the UsbService it depends on is shutting down. | 47 // Notifies the observer that the UsbService it depends on is shutting down. |
| 48 virtual void WillDestroyUsbService(); | 48 virtual void WillDestroyUsbService(); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // The file task runner reference is used for blocking I/O operations. | 51 // The file task runner reference is used for blocking I/O operations. |
| 52 // Returns nullptr when initialization fails. | 52 // Returns nullptr when initialization fails. |
| 53 static scoped_ptr<UsbService> Create( | 53 static std::unique_ptr<UsbService> Create( |
| 54 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); | 54 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
| 55 | 55 |
| 56 virtual ~UsbService(); | 56 virtual ~UsbService(); |
| 57 | 57 |
| 58 virtual scoped_refptr<UsbDevice> GetDevice(const std::string& guid) = 0; | 58 virtual scoped_refptr<UsbDevice> GetDevice(const std::string& guid) = 0; |
| 59 | 59 |
| 60 // Enumerates available devices. | 60 // Enumerates available devices. |
| 61 virtual void GetDevices(const GetDevicesCallback& callback) = 0; | 61 virtual void GetDevices(const GetDevicesCallback& callback) = 0; |
| 62 | 62 |
| 63 void AddObserver(Observer* observer); | 63 void AddObserver(Observer* observer); |
| 64 void RemoveObserver(Observer* observer); | 64 void RemoveObserver(Observer* observer); |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 UsbService(); | 67 UsbService(); |
| 68 | 68 |
| 69 void NotifyDeviceAdded(scoped_refptr<UsbDevice> device); | 69 void NotifyDeviceAdded(scoped_refptr<UsbDevice> device); |
| 70 void NotifyDeviceRemoved(scoped_refptr<UsbDevice> device); | 70 void NotifyDeviceRemoved(scoped_refptr<UsbDevice> device); |
| 71 | 71 |
| 72 base::ObserverList<Observer, true> observer_list_; | 72 base::ObserverList<Observer, true> observer_list_; |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 friend void base::DeletePointer<UsbService>(UsbService* service); | 75 friend void base::DeletePointer<UsbService>(UsbService* service); |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(UsbService); | 77 DISALLOW_COPY_AND_ASSIGN(UsbService); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace device | 80 } // namespace device |
| 81 | 81 |
| 82 #endif // DEVICE_USB_USB_SERVICE_H_ | 82 #endif // DEVICE_USB_USB_SERVICE_H_ |
| OLD | NEW |