OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/hid/device_monitor_linux.h" | 5 #include "device/hid/device_monitor_linux.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "device/udev_linux/udev.h" | 10 #include "device/udev_linux/udev.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 82 DCHECK(thread_checker_.CalledOnValidThread()); |
83 if (observer) | 83 if (observer) |
84 observers_.RemoveObserver(observer); | 84 observers_.RemoveObserver(observer); |
85 } | 85 } |
86 | 86 |
87 ScopedUdevDevicePtr DeviceMonitorLinux::GetDeviceFromPath( | 87 ScopedUdevDevicePtr DeviceMonitorLinux::GetDeviceFromPath( |
88 const std::string& path) { | 88 const std::string& path) { |
89 DCHECK(thread_checker_.CalledOnValidThread()); | 89 DCHECK(thread_checker_.CalledOnValidThread()); |
90 ScopedUdevDevicePtr device( | 90 ScopedUdevDevicePtr device( |
91 udev_device_new_from_syspath(udev_.get(), path.c_str())); | 91 udev_device_new_from_syspath(udev_.get(), path.c_str())); |
92 return device.Pass(); | 92 return device; |
93 } | 93 } |
94 | 94 |
95 void DeviceMonitorLinux::Enumerate(const EnumerateCallback& callback) { | 95 void DeviceMonitorLinux::Enumerate(const EnumerateCallback& callback) { |
96 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
97 ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev_.get())); | 97 ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev_.get())); |
98 | 98 |
99 if (!enumerate) { | 99 if (!enumerate) { |
100 LOG(ERROR) << "Failed to enumerate devices."; | 100 LOG(ERROR) << "Failed to enumerate devices."; |
101 return; | 101 return; |
102 } | 102 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void DeviceMonitorLinux::OnFileCanWriteWithoutBlocking(int fd) {} | 140 void DeviceMonitorLinux::OnFileCanWriteWithoutBlocking(int fd) {} |
141 | 141 |
142 DeviceMonitorLinux::~DeviceMonitorLinux() { | 142 DeviceMonitorLinux::~DeviceMonitorLinux() { |
143 DCHECK(thread_checker_.CalledOnValidThread()); | 143 DCHECK(thread_checker_.CalledOnValidThread()); |
144 base::MessageLoop::current()->RemoveDestructionObserver(this); | 144 base::MessageLoop::current()->RemoveDestructionObserver(this); |
145 monitor_watcher_.StopWatchingFileDescriptor(); | 145 monitor_watcher_.StopWatchingFileDescriptor(); |
146 close(monitor_fd_); | 146 close(monitor_fd_); |
147 } | 147 } |
148 | 148 |
149 } // namespace device | 149 } // namespace device |
OLD | NEW |