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/core/device_monitor_win.h" | 5 #include "device/core/device_monitor_win.h" |
6 | 6 |
7 #include <dbt.h> | 7 #include <dbt.h> |
8 #include <map> | 8 #include <map> |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 DeviceMonitorWin* device_monitor = nullptr; | 107 DeviceMonitorWin* device_monitor = nullptr; |
108 DEV_BROADCAST_DEVICEINTERFACE* db = | 108 DEV_BROADCAST_DEVICEINTERFACE* db = |
109 reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE*>(lparam); | 109 reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE*>(lparam); |
110 const auto& map_entry = device_monitors_.find(db->dbcc_classguid); | 110 const auto& map_entry = device_monitors_.find(db->dbcc_classguid); |
111 if (map_entry != device_monitors_.end()) { | 111 if (map_entry != device_monitors_.end()) { |
112 device_monitor = map_entry->second.get(); | 112 device_monitor = map_entry->second.get(); |
113 } | 113 } |
114 | 114 |
115 std::string device_path(base::SysWideToUTF8(db->dbcc_name)); | 115 std::string device_path(base::SysWideToUTF8(db->dbcc_name)); |
116 DCHECK(base::IsStringASCII(device_path)); | 116 DCHECK(base::IsStringASCII(device_path)); |
117 device_path = base::StringToLowerASCII(device_path); | 117 device_path = base::ToLowerASCII(device_path); |
118 | 118 |
119 if (wparam == DBT_DEVICEARRIVAL) { | 119 if (wparam == DBT_DEVICEARRIVAL) { |
120 if (device_monitor) { | 120 if (device_monitor) { |
121 device_monitor->NotifyDeviceAdded(db->dbcc_classguid, device_path); | 121 device_monitor->NotifyDeviceAdded(db->dbcc_classguid, device_path); |
122 } | 122 } |
123 all_device_monitor_.NotifyDeviceAdded(db->dbcc_classguid, device_path); | 123 all_device_monitor_.NotifyDeviceAdded(db->dbcc_classguid, device_path); |
124 } else if (wparam == DBT_DEVICEREMOVECOMPLETE) { | 124 } else if (wparam == DBT_DEVICEREMOVECOMPLETE) { |
125 if (device_monitor) { | 125 if (device_monitor) { |
126 device_monitor->NotifyDeviceRemoved(db->dbcc_classguid, device_path); | 126 device_monitor->NotifyDeviceRemoved(db->dbcc_classguid, device_path); |
127 } | 127 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 OnDeviceAdded(class_guid, device_path)); | 194 OnDeviceAdded(class_guid, device_path)); |
195 } | 195 } |
196 | 196 |
197 void DeviceMonitorWin::NotifyDeviceRemoved(const GUID& class_guid, | 197 void DeviceMonitorWin::NotifyDeviceRemoved(const GUID& class_guid, |
198 const std::string& device_path) { | 198 const std::string& device_path) { |
199 FOR_EACH_OBSERVER(Observer, observer_list_, | 199 FOR_EACH_OBSERVER(Observer, observer_list_, |
200 OnDeviceRemoved(class_guid, device_path)); | 200 OnDeviceRemoved(class_guid, device_path)); |
201 } | 201 } |
202 | 202 |
203 } // namespace device | 203 } // namespace device |
OLD | NEW |