Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: device/hid/device_monitor_linux.h

Issue 230503003: Udev-related methods are extracted from HidServiceLinux into individual service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | device/hid/device_monitor_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef DEVICE_HID_DEVICE_MONITOR_LINUX_H_
6 #define DEVICE_HID_DEVICE_MONITOR_LINUX_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/message_loop/message_pump_libevent.h"
13 #include "base/observer_list.h"
14 #include "device/hid/udev_common.h"
15
16 struct udev_device;
17
18 namespace device {
19
20 class DeviceMonitorLinux : public base::MessagePumpLibevent::Watcher {
21 public:
22 typedef base::Callback<void(udev_device* device)> EnumerateCallback;
23
24 class Observer {
25 public:
26 virtual ~Observer() {}
27 virtual void OnDeviceAdded(udev_device* device) = 0;
28 virtual void OnDeviceRemoved(udev_device* device) = 0;
29 };
30
31 DeviceMonitorLinux();
32 virtual ~DeviceMonitorLinux();
33
34 static DeviceMonitorLinux* GetInstance();
35 static bool HasInstance();
36
37 void AddObserver(Observer* observer);
38 void RemoveObserver(Observer* observer);
39
40 ScopedUdevDevicePtr GetDeviceFromPath(const std::string& path);
41 void Enumerate(const EnumerateCallback& callback);
42
43 // Implements base::MessagePumpLibevent::Watcher
44 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
45 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
46
47 private:
48 ScopedUdevPtr udev_;
49 ScopedUdevMonitorPtr monitor_;
50 int monitor_fd_;
51 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_;
52
53 ObserverList<Observer> observers_;
54
55 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorLinux);
56 };
57
58 } // namespace device
59
60 #endif // DEVICE_HID_DEVICE_MONITOR_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | device/hid/device_monitor_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698