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

Side by Side Diff: device/udev_linux/udev_watcher.h

Issue 2849953003: Use the task scheduler for blocking tasks in the USB service on Linux (Closed)
Patch Set: Remove more passing of the SequencedTaskRunner Created 3 years, 7 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/udev_linux/BUILD.gn ('k') | device/udev_linux/udev_watcher.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 2017 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_UDEV_LINUX_UDEV_WATCHER_H_
6 #define DEVICE_UDEV_LINUX_UDEV_WATCHER_H_
7
8 #include <memory>
9
10 #include "base/files/file_descriptor_watcher_posix.h"
11 #include "base/macros.h"
12 #include "base/sequence_checker.h"
13 #include "device/udev_linux/scoped_udev.h"
14
15 namespace device {
16
17 // This class wraps an instance of udev_monitor, watching for devices that are
18 // added and removed from the system. This class has sequence affinity.
19 class UdevWatcher {
20 public:
21 class Observer {
22 public:
23 virtual ~Observer();
24 virtual void OnDeviceAdded(ScopedUdevDevicePtr device);
25 virtual void OnDeviceRemoved(ScopedUdevDevicePtr device);
26 };
27
28 static std::unique_ptr<UdevWatcher> StartWatching(Observer* observer);
29
30 ~UdevWatcher();
31
32 // Synchronously enumerates the all devices known to udev, calling
33 // OnDeviceAdded on the provided Observer for each.
34 void EnumerateExistingDevices();
35
36 private:
37 UdevWatcher(ScopedUdevPtr udev,
38 ScopedUdevMonitorPtr udev_monitor,
39 int monitor_fd,
40 Observer* observer);
41
42 void OnMonitorReadable();
43
44 ScopedUdevPtr udev_;
45 ScopedUdevMonitorPtr udev_monitor_;
46 Observer* observer_;
47 std::unique_ptr<base::FileDescriptorWatcher::Controller> file_watcher_;
48 base::SequenceChecker sequence_checker_;
49
50 DISALLOW_COPY_AND_ASSIGN(UdevWatcher);
51 };
52
53 } // namespace device
54
55 #endif // DEVICE_UDEV_LINUX_UDEV_WATCHER_H_
OLDNEW
« no previous file with comments | « device/udev_linux/BUILD.gn ('k') | device/udev_linux/udev_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698