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

Unified Diff: ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc

Issue 250793005: Refactor Udev device support in Ozone and add a DRM hotplug monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
Index: ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc
diff --git a/ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc b/ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..481ea3d2a465328e0ffce665d5939ff958425c5a
--- /dev/null
+++ b/ui/ozone/platform/dri/chromeos/display_event_listener_udev.cc
@@ -0,0 +1,44 @@
+// 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.
+
+#include "ui/ozone/platform/dri/chromeos/display_event_listener_udev.h"
+
+#include "base/logging.h"
+#include "ui/events/ozone/device_udev.h"
+
+namespace ui {
+
+namespace {
+const char kSubsystemDrm[] = "drm";
+} // namespace
+
+DisplayEventListenerUdev::DisplayEventListenerUdev(DeviceUdev* udev)
+ : udev_(udev) {}
+
+DisplayEventListenerUdev::~DisplayEventListenerUdev() {
+ udev_->UnregisterDeviceMonitor(this);
+ callback_.Reset();
+}
+
+void DisplayEventListenerUdev::StartMonitoring(
+ const DisplayEventCallback& callback) {
+ callback_ = callback;
+
+ if (!udev_->RegisterDeviceMonitor(this, kSubsystemDrm))
+ LOG(ERROR) << "Failed to start monitoring changes to DRM via Udev";
+}
+
+void DisplayEventListenerUdev::HandleUdevEvent(scoped_udev_device device) {
+ const char* device_path = udev_device_get_devnode(device.get());
+ const char* action = udev_device_get_action(device.get());
+ const char* hotplug = udev_device_get_property_value(device.get(), "HOTPLUG");
+
+ if (!device_path || !action || !hotplug)
+ return;
+
+ if (!strcmp(action, "change") && !strcmp(hotplug, "1"))
+ callback_.Run();
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698