summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_service_linux.h
blob: 62bb4c7a7080680e685f13dfd4e39a5b3f70d33d (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
// 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_LINUX_H_
#define DEVICE_HID_HID_SERVICE_LINUX_H_

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "device/hid/device_monitor_linux.h"
#include "device/hid/hid_device_info.h"
#include "device/hid/hid_service.h"

struct udev_device;

namespace device {

class HidConnection;

class HidServiceLinux : public HidService,
                        public DeviceMonitorLinux::Observer {
 public:
  HidServiceLinux(scoped_refptr<base::MessageLoopProxy> ui_message_loop);

  virtual scoped_refptr<HidConnection> Connect(const HidDeviceId& device_id)
      OVERRIDE;

  // Implements DeviceMonitorLinux::Observer:
  virtual void OnDeviceAdded(udev_device* device) OVERRIDE;
  virtual void OnDeviceRemoved(udev_device* device) OVERRIDE;

 private:
  virtual ~HidServiceLinux();

  void OnRequestAccessComplete(
      const std::string& path,
      scoped_ptr<HidDeviceInfo> device_info,
      bool success);

  scoped_refptr<base::MessageLoopProxy> ui_message_loop_;

  base::WeakPtrFactory<HidServiceLinux> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(HidServiceLinux);
};

}  // namespace device

#endif  // DEVICE_HID_HID_SERVICE_LINUX_H_