Update Smart lock strings in chrome://settings.
[chromium-blink-merge.git] / device / hid / hid_service.h
bloba3f71320416d26b4c9823b37debb36feb739bb8b
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 typedef base::Callback<void(scoped_refptr<HidConnection> connection)>
24 ConnectCallback;
26 static HidService* GetInstance(
27 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
30 // Enumerates and returns a list of device identifiers.
31 virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
33 // Fills in a DeviceInfo struct with info for the given device_id.
34 // Returns |true| if successful or |false| if |device_id| is invalid.
35 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
37 // Opens a connection to a device. The callback will be run with null on
38 // failure.
39 virtual void Connect(const HidDeviceId& device_id,
40 const ConnectCallback& callback) = 0;
42 protected:
43 friend class HidConnectionTest;
45 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
47 HidService();
48 virtual ~HidService();
50 void AddDevice(const HidDeviceInfo& info);
51 void RemoveDevice(const HidDeviceId& device_id);
53 const DeviceMap& devices() const { return devices_; }
55 base::ThreadChecker thread_checker_;
57 private:
58 class Destroyer;
60 DeviceMap devices_;
62 DISALLOW_COPY_AND_ASSIGN(HidService);
65 } // namespace device
67 #endif // DEVICE_HID_HID_SERVICE_H_