Removing uses of X11 native key events.
[chromium-blink-merge.git] / device / hid / hid_service.h
blobc3702038b4b19f2e57635c006304cd942fa70a92
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_HID_HID_SERVICE_H_
6 #define DEVICE_HID_HID_SERVICE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_checker.h"
15 #include "device/hid/hid_device_info.h"
17 namespace device {
19 class HidConnection;
21 class HidService {
22 public:
23 static HidService* GetInstance(
24 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
26 // Enumerates and returns a list of device identifiers.
27 virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
29 // Fills in a DeviceInfo struct with info for the given device_id.
30 // Returns |true| if successful or |false| if |device_id| is invalid.
31 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
33 virtual scoped_refptr<HidConnection> Connect(
34 const HidDeviceId& device_id) = 0;
36 protected:
37 friend class HidConnectionTest;
39 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
41 HidService();
42 virtual ~HidService();
44 void AddDevice(const HidDeviceInfo& info);
45 void RemoveDevice(const HidDeviceId& device_id);
46 const DeviceMap& GetDevicesNoEnumerate() const;
48 base::ThreadChecker thread_checker_;
50 private:
51 class Destroyer;
53 DeviceMap devices_;
55 DISALLOW_COPY_AND_ASSIGN(HidService);
58 } // namespace device
60 #endif // DEVICE_HID_HID_SERVICE_H_