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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/hid/device_monitor_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/device_monitor_linux.h
diff --git a/device/hid/device_monitor_linux.h b/device/hid/device_monitor_linux.h
new file mode 100644
index 0000000000000000000000000000000000000000..d198473186ac0567bbf8a4d2afb9b9c4fe2a589b
--- /dev/null
+++ b/device/hid/device_monitor_linux.h
@@ -0,0 +1,60 @@
+// 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_DEVICE_MONITOR_LINUX_H_
+#define DEVICE_HID_DEVICE_MONITOR_LINUX_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "base/message_loop/message_pump_libevent.h"
+#include "base/observer_list.h"
+#include "device/hid/udev_common.h"
+
+struct udev_device;
+
+namespace device {
+
+class DeviceMonitorLinux : public base::MessagePumpLibevent::Watcher {
+ public:
+ typedef base::Callback<void(udev_device* device)> EnumerateCallback;
+
+ class Observer {
+ public:
+ virtual ~Observer() {}
+ virtual void OnDeviceAdded(udev_device* device) = 0;
+ virtual void OnDeviceRemoved(udev_device* device) = 0;
+ };
+
+ DeviceMonitorLinux();
+ virtual ~DeviceMonitorLinux();
+
+ static DeviceMonitorLinux* GetInstance();
+ static bool HasInstance();
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ ScopedUdevDevicePtr GetDeviceFromPath(const std::string& path);
+ void Enumerate(const EnumerateCallback& callback);
+
+ // Implements base::MessagePumpLibevent::Watcher
+ virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
+ virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
+
+ private:
+ ScopedUdevPtr udev_;
+ ScopedUdevMonitorPtr monitor_;
+ int monitor_fd_;
+ base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_;
+
+ ObserverList<Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceMonitorLinux);
+};
+
+} // namespace device
+
+#endif // DEVICE_HID_DEVICE_MONITOR_LINUX_H_
« 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