| 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_HID_HID_SERVICE_H_ | 5 #ifndef DEVICE_HID_HID_SERVICE_H_ |
| 6 #define DEVICE_HID_HID_SERVICE_H_ | 6 #define DEVICE_HID_HID_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Returns |nullptr| if |device_id| is invalid. | 54 // Returns |nullptr| if |device_id| is invalid. |
| 55 scoped_refptr<HidDeviceInfo> GetDeviceInfo( | 55 scoped_refptr<HidDeviceInfo> GetDeviceInfo( |
| 56 const HidDeviceId& device_id) const; | 56 const HidDeviceId& device_id) const; |
| 57 | 57 |
| 58 // Opens a connection to a device. The callback will be run with null on | 58 // Opens a connection to a device. The callback will be run with null on |
| 59 // failure. | 59 // failure. |
| 60 virtual void Connect(const HidDeviceId& device_id, | 60 virtual void Connect(const HidDeviceId& device_id, |
| 61 const ConnectCallback& callback) = 0; | 61 const ConnectCallback& callback) = 0; |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 friend void base::DeletePointer<HidService>(HidService* service); | 64 friend struct base::DefaultDeleter<HidService>; |
| 65 friend class HidConnectionTest; | 65 friend class HidConnectionTest; |
| 66 | 66 |
| 67 typedef std::map<HidDeviceId, scoped_refptr<HidDeviceInfo>> DeviceMap; | 67 typedef std::map<HidDeviceId, scoped_refptr<HidDeviceInfo>> DeviceMap; |
| 68 | 68 |
| 69 HidService(); | 69 HidService(); |
| 70 virtual ~HidService(); | 70 virtual ~HidService(); |
| 71 | 71 |
| 72 void AddDevice(scoped_refptr<HidDeviceInfo> info); | 72 void AddDevice(scoped_refptr<HidDeviceInfo> info); |
| 73 void RemoveDevice(const HidDeviceId& device_id); | 73 void RemoveDevice(const HidDeviceId& device_id); |
| 74 void FirstEnumerationComplete(); | 74 void FirstEnumerationComplete(); |
| 75 | 75 |
| 76 const DeviceMap& devices() const { return devices_; } | 76 const DeviceMap& devices() const { return devices_; } |
| 77 | 77 |
| 78 base::ThreadChecker thread_checker_; | 78 base::ThreadChecker thread_checker_; |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 DeviceMap devices_; | 81 DeviceMap devices_; |
| 82 bool enumeration_ready_; | 82 bool enumeration_ready_; |
| 83 std::vector<GetDevicesCallback> pending_enumerations_; | 83 std::vector<GetDevicesCallback> pending_enumerations_; |
| 84 ObserverList<Observer> observer_list_; | 84 ObserverList<Observer> observer_list_; |
| 85 | 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(HidService); | 86 DISALLOW_COPY_AND_ASSIGN(HidService); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace device | 89 } // namespace device |
| 90 | 90 |
| 91 #endif // DEVICE_HID_HID_SERVICE_H_ | 91 #endif // DEVICE_HID_HID_SERVICE_H_ |
| OLD | NEW |