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

Side by Side Diff: device/base/device_monitor_linux.cc

Issue 2417043002: Move device/core files to device/base directory. (Closed)
Patch Set: Fix ChromeOS build Created 4 years, 2 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/base/device_monitor_linux.h ('k') | device/base/device_monitor_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/core/device_monitor_linux.h" 5 #include "device/base/device_monitor_linux.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "device/udev_linux/udev.h" 13 #include "device/udev_linux/udev.h"
14 14
15 namespace device { 15 namespace device {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 i = udev_list_entry_get_next(i)) { 104 i = udev_list_entry_get_next(i)) {
105 ScopedUdevDevicePtr device( 105 ScopedUdevDevicePtr device(
106 udev_device_new_from_syspath(udev_.get(), udev_list_entry_get_name(i))); 106 udev_device_new_from_syspath(udev_.get(), udev_list_entry_get_name(i)));
107 if (device) 107 if (device)
108 callback.Run(device.get()); 108 callback.Run(device.get());
109 } 109 }
110 } 110 }
111 111
112 void DeviceMonitorLinux::WillDestroyCurrentMessageLoop() { 112 void DeviceMonitorLinux::WillDestroyCurrentMessageLoop() {
113 DCHECK(thread_checker_.CalledOnValidThread()); 113 DCHECK(thread_checker_.CalledOnValidThread());
114 FOR_EACH_OBSERVER(Observer, observers_, WillDestroyMonitorMessageLoop()); 114 for (auto& observer : observers_)
115 observer.WillDestroyMonitorMessageLoop();
115 g_device_monitor_linux_ptr.Get().reset(nullptr); 116 g_device_monitor_linux_ptr.Get().reset(nullptr);
116 } 117 }
117 118
118 DeviceMonitorLinux::~DeviceMonitorLinux() { 119 DeviceMonitorLinux::~DeviceMonitorLinux() {
119 DCHECK(thread_checker_.CalledOnValidThread()); 120 DCHECK(thread_checker_.CalledOnValidThread());
120 base::MessageLoop::current()->RemoveDestructionObserver(this); 121 base::MessageLoop::current()->RemoveDestructionObserver(this);
121 close(monitor_fd_); 122 close(monitor_fd_);
122 } 123 }
123 124
124 void DeviceMonitorLinux::OnMonitorCanReadWithoutBlocking() { 125 void DeviceMonitorLinux::OnMonitorCanReadWithoutBlocking() {
125 DCHECK(thread_checker_.CalledOnValidThread()); 126 DCHECK(thread_checker_.CalledOnValidThread());
126 127
127 ScopedUdevDevicePtr device(udev_monitor_receive_device(monitor_.get())); 128 ScopedUdevDevicePtr device(udev_monitor_receive_device(monitor_.get()));
128 if (!device) 129 if (!device)
129 return; 130 return;
130 131
131 std::string action(udev_device_get_action(device.get())); 132 std::string action(udev_device_get_action(device.get()));
132 if (action == kUdevActionAdd) 133 if (action == kUdevActionAdd) {
133 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceAdded(device.get())); 134 for (auto& observer : observers_)
134 else if (action == kUdevActionRemove) 135 observer.OnDeviceAdded(device.get());
135 FOR_EACH_OBSERVER(Observer, observers_, OnDeviceRemoved(device.get())); 136 } else if (action == kUdevActionRemove) {
137 for (auto& observer : observers_)
138 observer.OnDeviceRemoved(device.get());
139 }
136 } 140 }
137 141
138 } // namespace device 142 } // namespace device
OLDNEW
« no previous file with comments | « device/base/device_monitor_linux.h ('k') | device/base/device_monitor_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698