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

Side by Side Diff: content/browser/device_monitor_udev.cc

Issue 1008613002: favor DCHECK_CURRENTLY_ON for better logs in content/browser/[a-d]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // libudev is used for monitoring device changes. 5 // libudev is used for monitoring device changes.
6 6
7 #include "content/browser/device_monitor_udev.h" 7 #include "content/browser/device_monitor_udev.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 27 matching lines...) Expand all
38 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); 38 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
39 BrowserThread::PostTask(BrowserThread::IO, 39 BrowserThread::PostTask(BrowserThread::IO,
40 FROM_HERE, 40 FROM_HERE,
41 base::Bind(&DeviceMonitorLinux::Initialize, base::Unretained(this))); 41 base::Bind(&DeviceMonitorLinux::Initialize, base::Unretained(this)));
42 } 42 }
43 43
44 DeviceMonitorLinux::~DeviceMonitorLinux() { 44 DeviceMonitorLinux::~DeviceMonitorLinux() {
45 } 45 }
46 46
47 void DeviceMonitorLinux::Initialize() { 47 void DeviceMonitorLinux::Initialize() {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 48 DCHECK_CURRENTLY_ON(BrowserThread::IO);
49 49
50 // We want to be notified of IO message loop destruction to delete |udev_|. 50 // We want to be notified of IO message loop destruction to delete |udev_|.
51 base::MessageLoop::current()->AddDestructionObserver(this); 51 base::MessageLoop::current()->AddDestructionObserver(this);
52 52
53 std::vector<UdevLinux::UdevMonitorFilter> filters; 53 std::vector<UdevLinux::UdevMonitorFilter> filters;
54 for (size_t i = 0; i < arraysize(kSubsystemMap); ++i) { 54 for (size_t i = 0; i < arraysize(kSubsystemMap); ++i) {
55 filters.push_back(UdevLinux::UdevMonitorFilter( 55 filters.push_back(UdevLinux::UdevMonitorFilter(
56 kSubsystemMap[i].subsystem, kSubsystemMap[i].devtype)); 56 kSubsystemMap[i].subsystem, kSubsystemMap[i].devtype));
57 } 57 }
58 udev_.reset(new UdevLinux(filters, 58 udev_.reset(new UdevLinux(filters,
59 base::Bind(&DeviceMonitorLinux::OnDevicesChanged, 59 base::Bind(&DeviceMonitorLinux::OnDevicesChanged,
60 base::Unretained(this)))); 60 base::Unretained(this))));
61 } 61 }
62 62
63 void DeviceMonitorLinux::WillDestroyCurrentMessageLoop() { 63 void DeviceMonitorLinux::WillDestroyCurrentMessageLoop() {
64 // Called on IO thread. 64 // Called on IO thread.
65 udev_.reset(); 65 udev_.reset();
66 } 66 }
67 67
68 void DeviceMonitorLinux::OnDevicesChanged(udev_device* device) { 68 void DeviceMonitorLinux::OnDevicesChanged(udev_device* device) {
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 69 DCHECK_CURRENTLY_ON(BrowserThread::IO);
70 DCHECK(device); 70 DCHECK(device);
71 71
72 base::SystemMonitor::DeviceType device_type = 72 base::SystemMonitor::DeviceType device_type =
73 base::SystemMonitor::DEVTYPE_UNKNOWN; 73 base::SystemMonitor::DEVTYPE_UNKNOWN;
74 std::string subsystem(device::udev_device_get_subsystem(device)); 74 std::string subsystem(device::udev_device_get_subsystem(device));
75 for (size_t i = 0; i < arraysize(kSubsystemMap); ++i) { 75 for (size_t i = 0; i < arraysize(kSubsystemMap); ++i) {
76 if (subsystem == kSubsystemMap[i].subsystem) { 76 if (subsystem == kSubsystemMap[i].subsystem) {
77 device_type = kSubsystemMap[i].device_type; 77 device_type = kSubsystemMap[i].device_type;
78 break; 78 break;
79 } 79 }
80 } 80 }
81 DCHECK_NE(device_type, base::SystemMonitor::DEVTYPE_UNKNOWN); 81 DCHECK_NE(device_type, base::SystemMonitor::DEVTYPE_UNKNOWN);
82 82
83 base::SystemMonitor::Get()->ProcessDevicesChanged(device_type); 83 base::SystemMonitor::Get()->ProcessDevicesChanged(device_type);
84 } 84 }
85 85
86 } // namespace content 86 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/device_monitor_mac.mm ('k') | content/browser/device_sensors/device_light_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698