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

Unified Diff: device/hid/input_service_linux.cc

Issue 2014933002: Move DeviceMonitorLinux to //device/core. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment for boolean parameter. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/input_service_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/input_service_linux.cc
diff --git a/device/hid/input_service_linux.cc b/device/hid/input_service_linux.cc
index d8053028fb67d847a0e3fdf8c1193f5fc927315f..4df2cb570ca10942b318e577cab25fd9185d5d41 100644
--- a/device/hid/input_service_linux.cc
+++ b/device/hid/input_service_linux.cc
@@ -10,9 +10,11 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/scoped_observer.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
+#include "device/core/device_monitor_linux.h"
#include "device/udev_linux/udev.h"
namespace device {
@@ -89,6 +91,7 @@ class InputServiceLinuxImpl : public InputServiceLinux,
// Implements DeviceMonitorLinux::Observer:
void OnDeviceAdded(udev_device* device) override;
void OnDeviceRemoved(udev_device* device) override;
+ void WillDestroyMonitorMessageLoop() override;
private:
friend class InputServiceLinux;
@@ -96,22 +99,21 @@ class InputServiceLinuxImpl : public InputServiceLinux,
InputServiceLinuxImpl();
~InputServiceLinuxImpl() override;
+ ScopedObserver<DeviceMonitorLinux, DeviceMonitorLinux::Observer> observer_;
+
DISALLOW_COPY_AND_ASSIGN(InputServiceLinuxImpl);
};
-InputServiceLinuxImpl::InputServiceLinuxImpl() {
+InputServiceLinuxImpl::InputServiceLinuxImpl() : observer_(this) {
base::ThreadRestrictions::AssertIOAllowed();
- base::MessageLoop::current()->AddDestructionObserver(this);
- DeviceMonitorLinux::GetInstance()->AddObserver(this);
- DeviceMonitorLinux::GetInstance()->Enumerate(base::Bind(
- &InputServiceLinuxImpl::OnDeviceAdded, base::Unretained(this)));
+ DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance();
+ observer_.Add(monitor);
+ monitor->Enumerate(base::Bind(&InputServiceLinuxImpl::OnDeviceAdded,
+ base::Unretained(this)));
}
InputServiceLinuxImpl::~InputServiceLinuxImpl() {
- if (DeviceMonitorLinux::HasInstance())
- DeviceMonitorLinux::GetInstance()->RemoveObserver(this);
- base::MessageLoop::current()->RemoveDestructionObserver(this);
}
void InputServiceLinuxImpl::OnDeviceAdded(udev_device* device) {
@@ -161,6 +163,11 @@ void InputServiceLinuxImpl::OnDeviceRemoved(udev_device* device) {
RemoveDevice(devnode);
}
+void InputServiceLinuxImpl::WillDestroyMonitorMessageLoop() {
+ DCHECK(CalledOnValidThread());
+ g_input_service_linux_ptr.Get().reset(nullptr);
+}
+
} // namespace
InputServiceLinux::InputDeviceInfo::InputDeviceInfo()
@@ -232,11 +239,6 @@ bool InputServiceLinux::GetDeviceInfo(const std::string& id,
return true;
}
-void InputServiceLinux::WillDestroyCurrentMessageLoop() {
- DCHECK(CalledOnValidThread());
- g_input_service_linux_ptr.Get().reset(NULL);
-}
-
void InputServiceLinux::AddDevice(const InputDeviceInfo& info) {
devices_[info.id] = info;
FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceAdded(info));
« no previous file with comments | « device/hid/input_service_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698