| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 22 matching lines...) Expand all Loading... |
| 33 public: | 33 public: |
| 34 // Must be called on FILE thread. | 34 // Must be called on FILE thread. |
| 35 static HidService* GetInstance(); | 35 static HidService* GetInstance(); |
| 36 | 36 |
| 37 // Enumerates and returns a list of device identifiers. | 37 // Enumerates and returns a list of device identifiers. |
| 38 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); | 38 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); |
| 39 | 39 |
| 40 // Fills in the device info struct of the given device_id. | 40 // Fills in the device info struct of the given device_id. |
| 41 // Returns true if succeed. | 41 // Returns true if succeed. |
| 42 // Returns false if the device_id is invalid, with info untouched. | 42 // Returns false if the device_id is invalid, with info untouched. |
| 43 bool GetInfo(std::string device_id, HidDeviceInfo* info) const; | 43 bool GetInfo(const std::string& device_id, HidDeviceInfo* info) const; |
| 44 | 44 |
| 45 virtual scoped_refptr<HidConnection> Connect( | 45 virtual scoped_refptr<HidConnection> Connect( |
| 46 std::string platform_device_id) = 0; | 46 const std::string& device_id) = 0; |
| 47 | 47 |
| 48 // Implements base::MessageLoop::DestructionObserver | 48 // Implements base::MessageLoop::DestructionObserver |
| 49 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 49 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
| 50 | 50 |
| 51 // Gets whether the HidService have been successfully initialized. | 51 // Gets whether the HidService have been successfully initialized. |
| 52 bool initialized() const { return initialized_; } | 52 bool initialized() const { return initialized_; } |
| 53 | 53 |
| 54 protected: | 54 protected: |
| 55 friend class HidServiceContainer; | 55 friend class HidServiceContainer; |
| 56 friend struct base::DefaultDeleter<HidService>; | 56 friend struct base::DefaultDeleter<HidService>; |
| 57 friend class HidConnectionTest; | 57 friend class HidConnectionTest; |
| 58 | 58 |
| 59 HidService(); | 59 HidService(); |
| 60 virtual ~HidService(); | 60 virtual ~HidService(); |
| 61 | 61 |
| 62 static HidService* CreateInstance(); | 62 static HidService* CreateInstance(); |
| 63 | 63 |
| 64 virtual void AddDevice(HidDeviceInfo info); | 64 virtual void AddDevice(HidDeviceInfo info); |
| 65 virtual void RemoveDevice(std::string platform_device_id); | 65 virtual void RemoveDevice(const std::string& device_id); |
| 66 | 66 |
| 67 typedef std::map<std::string, HidDeviceInfo> DeviceMap; | 67 typedef std::map<std::string, HidDeviceInfo> DeviceMap; |
| 68 DeviceMap devices_; | 68 DeviceMap devices_; |
| 69 | 69 |
| 70 bool initialized_; | 70 bool initialized_; |
| 71 | 71 |
| 72 base::ThreadChecker thread_checker_; | 72 base::ThreadChecker thread_checker_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(HidService); | 74 DISALLOW_COPY_AND_ASSIGN(HidService); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace device | 77 } // namespace device |
| 78 | 78 |
| 79 #endif // DEVICE_HID_HID_SERVICE_H_ | 79 #endif // DEVICE_HID_HID_SERVICE_H_ |
| OLD | NEW |