OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/system_monitor/system_monitor.h" | 5 #include "base/system_monitor/system_monitor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // This can happen if our unique id scheme fails. Ignore the incoming | 97 // This can happen if our unique id scheme fails. Ignore the incoming |
98 // non-unique attachment. | 98 // non-unique attachment. |
99 return; | 99 return; |
100 } | 100 } |
101 media_device_map_.insert(std::make_pair(id, info)); | 101 media_device_map_.insert(std::make_pair(id, info)); |
102 NotifyMediaDeviceAttached(id, name, type, location); | 102 NotifyMediaDeviceAttached(id, name, type, location); |
103 } | 103 } |
104 | 104 |
105 void SystemMonitor::ProcessMediaDeviceDetached(const std::string& id) { | 105 void SystemMonitor::ProcessMediaDeviceDetached(const std::string& id) { |
106 MediaDeviceMap::iterator it = media_device_map_.find(id); | 106 MediaDeviceMap::iterator it = media_device_map_.find(id); |
107 if (it != media_device_map_.end()) | 107 if (it == media_device_map_.end()) |
108 media_device_map_.erase(it); | 108 return; |
| 109 media_device_map_.erase(it); |
109 NotifyMediaDeviceDetached(id); | 110 NotifyMediaDeviceDetached(id); |
110 } | 111 } |
111 | 112 |
112 std::vector<SystemMonitor::MediaDeviceInfo> | 113 std::vector<SystemMonitor::MediaDeviceInfo> |
113 SystemMonitor::GetAttachedMediaDevices() const { | 114 SystemMonitor::GetAttachedMediaDevices() const { |
114 std::vector<MediaDeviceInfo> results; | 115 std::vector<MediaDeviceInfo> results; |
115 for (MediaDeviceMap::const_iterator it = media_device_map_.begin(); | 116 for (MediaDeviceMap::const_iterator it = media_device_map_.begin(); |
116 it != media_device_map_.end(); | 117 it != media_device_map_.end(); |
117 ++it) { | 118 ++it) { |
118 results.push_back(it->second); | 119 results.push_back(it->second); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 void SystemMonitor::NotifyResume() { | 175 void SystemMonitor::NotifyResume() { |
175 DVLOG(1) << "Power Resuming"; | 176 DVLOG(1) << "Power Resuming"; |
176 power_observer_list_->Notify(&PowerObserver::OnResume); | 177 power_observer_list_->Notify(&PowerObserver::OnResume); |
177 } | 178 } |
178 | 179 |
179 void SystemMonitor::BatteryCheck() { | 180 void SystemMonitor::BatteryCheck() { |
180 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 181 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); |
181 } | 182 } |
182 | 183 |
183 } // namespace base | 184 } // namespace base |
OLD | NEW |