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

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

Issue 2417043002: Move device/core files to device/base directory. (Closed)
Patch Set: Fix ChromeOS build Created 4 years, 2 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
« no previous file with comments | « device/core/device_info_query_win.cc ('k') | device/core/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 <memory>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "base/files/file_descriptor_watcher_posix.h"
13 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h"
15 #include "base/observer_list.h"
16 #include "base/threading/thread_checker.h"
17 #include "device/core/device_core_export.h"
18 #include "device/udev_linux/scoped_udev.h"
19
20 struct udev_device;
21
22 namespace device {
23
24 // This class listends for notifications from libudev about
25 // connected/disconnected devices. This class is *NOT* thread-safe.
26 class DEVICE_CORE_EXPORT DeviceMonitorLinux
27 : public base::MessageLoop::DestructionObserver {
28 public:
29 typedef base::Callback<void(udev_device* device)> EnumerateCallback;
30
31 class Observer {
32 public:
33 virtual ~Observer() {}
34 virtual void OnDeviceAdded(udev_device* device) = 0;
35 virtual void OnDeviceRemoved(udev_device* device) = 0;
36 virtual void WillDestroyMonitorMessageLoop() = 0;
37 };
38
39 DeviceMonitorLinux();
40
41 static DeviceMonitorLinux* GetInstance();
42
43 void AddObserver(Observer* observer);
44 void RemoveObserver(Observer* observer);
45
46 ScopedUdevDevicePtr GetDeviceFromPath(const std::string& path);
47 void Enumerate(const EnumerateCallback& callback);
48
49 // Implements base::MessageLoop::DestructionObserver
50 void WillDestroyCurrentMessageLoop() override;
51
52 private:
53 friend std::default_delete<DeviceMonitorLinux>;
54
55 ~DeviceMonitorLinux() override;
56
57 void OnMonitorCanReadWithoutBlocking();
58
59 ScopedUdevPtr udev_;
60 ScopedUdevMonitorPtr monitor_;
61 int monitor_fd_;
62 std::unique_ptr<base::FileDescriptorWatcher::Controller>
63 monitor_watch_controller_;
64
65 base::ObserverList<Observer, true> observers_;
66
67 base::ThreadChecker thread_checker_;
68
69 DISALLOW_COPY_AND_ASSIGN(DeviceMonitorLinux);
70 };
71
72 } // namespace device
73
74 #endif // DEVICE_HID_DEVICE_MONITOR_LINUX_H_
OLDNEW
« no previous file with comments | « device/core/device_info_query_win.cc ('k') | device/core/device_monitor_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698