blob: cc7813b9b4aeefae70b819bd44028c36574b5d3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_HID_HID_SERVICE_H_
#define DEVICE_HID_HID_SERVICE_H_
#include <map>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "device/hid/hid_device_info.h"
namespace device {
class HidConnection;
class HidService {
public:
static HidService* GetInstance(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
virtual ~HidService();
// Enumerates and returns a list of device identifiers.
virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
// Fills in a DeviceInfo struct with info for the given device_id.
// Returns |true| if successful or |false| if |device_id| is invalid.
bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
virtual scoped_refptr<HidConnection> Connect(
const HidDeviceId& device_id) = 0;
protected:
friend class HidConnectionTest;
typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
HidService();
void AddDevice(const HidDeviceInfo& info);
void RemoveDevice(const HidDeviceId& device_id);
const DeviceMap& GetDevicesNoEnumerate() const;
base::ThreadChecker thread_checker_;
private:
DeviceMap devices_;
DISALLOW_COPY_AND_ASSIGN(HidService);
};
} // namespace device
#endif // DEVICE_HID_HID_SERVICE_H_
|