Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "device/hid/hid_device_info.h" | 15 #include "device/hid/hid_device_info.h" |
| 16 | 16 |
| 17 namespace device { | 17 namespace device { |
| 18 | 18 |
| 19 class HidConnection; | 19 class HidConnection; |
| 20 | 20 |
| 21 class HidService { | 21 class HidService { |
| 22 public: | 22 public: |
| 23 static HidService* GetInstance( | 23 static HidService* GetInstance( |
| 24 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 24 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 25 | 25 |
| 26 virtual ~HidService(); | |
| 27 | |
| 28 // Enumerates and returns a list of device identifiers. | 26 // Enumerates and returns a list of device identifiers. |
| 29 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); | 27 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); |
| 30 | 28 |
| 31 // Fills in a DeviceInfo struct with info for the given device_id. | 29 // Fills in a DeviceInfo struct with info for the given device_id. |
| 32 // Returns |true| if successful or |false| if |device_id| is invalid. | 30 // Returns |true| if successful or |false| if |device_id| is invalid. |
| 33 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; | 31 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; |
| 34 | 32 |
| 35 virtual scoped_refptr<HidConnection> Connect( | 33 virtual scoped_refptr<HidConnection> Connect( |
| 36 const HidDeviceId& device_id) = 0; | 34 const HidDeviceId& device_id) = 0; |
| 37 | 35 |
| 38 protected: | 36 protected: |
| 39 friend class HidConnectionTest; | 37 friend class HidConnectionTest; |
| 40 | 38 |
| 41 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap; | 39 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap; |
| 42 | 40 |
| 43 HidService(); | 41 HidService(); |
| 42 virtual ~HidService(); | |
|
Ken Rockot(use gerrit already)
2014/09/05 19:52:04
Any reason not to make it private?
Reilly Grant (use Gerrit)
2014/09/05 20:19:05
Sub-classes.
| |
| 44 | 43 |
| 45 void AddDevice(const HidDeviceInfo& info); | 44 void AddDevice(const HidDeviceInfo& info); |
| 46 void RemoveDevice(const HidDeviceId& device_id); | 45 void RemoveDevice(const HidDeviceId& device_id); |
| 47 const DeviceMap& GetDevicesNoEnumerate() const; | 46 const DeviceMap& GetDevicesNoEnumerate() const; |
| 48 | 47 |
| 49 base::ThreadChecker thread_checker_; | 48 base::ThreadChecker thread_checker_; |
| 50 | 49 |
| 51 private: | 50 private: |
| 51 class Destroyer; | |
| 52 | |
| 52 DeviceMap devices_; | 53 DeviceMap devices_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(HidService); | 55 DISALLOW_COPY_AND_ASSIGN(HidService); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace device | 58 } // namespace device |
| 58 | 59 |
| 59 #endif // DEVICE_HID_HID_SERVICE_H_ | 60 #endif // DEVICE_HID_HID_SERVICE_H_ |
| OLD | NEW |