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 "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 void SystemMonitor::ProcessDevicesChanged() { | 83 void SystemMonitor::ProcessDevicesChanged() { |
84 NotifyDevicesChanged(); | 84 NotifyDevicesChanged(); |
85 } | 85 } |
86 | 86 |
87 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id, | 87 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id, |
88 const std::string& name, | 88 const std::string& name, |
89 const FilePath& path) { | 89 const FilePath& path) { |
| 90 media_device_map_.insert(std::make_pair(id, std::make_pair(name, path))); |
90 NotifyMediaDeviceAttached(id, name, path); | 91 NotifyMediaDeviceAttached(id, name, path); |
91 } | 92 } |
92 | 93 |
93 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) { | 94 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) { |
| 95 MediaDeviceMap::iterator it = media_device_map_.find(id); |
| 96 if (it != media_device_map_.end()) |
| 97 media_device_map_.erase(it); |
94 NotifyMediaDeviceDetached(id); | 98 NotifyMediaDeviceDetached(id); |
95 } | 99 } |
96 | 100 |
| 101 void SystemMonitor::GetMediaDevices(std::vector<MediaDeviceInfo>* results) { |
| 102 for (MediaDeviceMap::const_iterator it = media_device_map_.begin(); |
| 103 it != media_device_map_.end(); |
| 104 ++it) { |
| 105 results->push_back(it->second); |
| 106 } |
| 107 } |
| 108 |
97 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { | 109 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { |
98 power_observer_list_->AddObserver(obs); | 110 power_observer_list_->AddObserver(obs); |
99 } | 111 } |
100 | 112 |
101 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { | 113 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { |
102 power_observer_list_->RemoveObserver(obs); | 114 power_observer_list_->RemoveObserver(obs); |
103 } | 115 } |
104 | 116 |
105 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { | 117 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { |
106 devices_changed_observer_list_->AddObserver(obs); | 118 devices_changed_observer_list_->AddObserver(obs); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 void SystemMonitor::NotifyResume() { | 157 void SystemMonitor::NotifyResume() { |
146 DVLOG(1) << "Power Resuming"; | 158 DVLOG(1) << "Power Resuming"; |
147 power_observer_list_->Notify(&PowerObserver::OnResume); | 159 power_observer_list_->Notify(&PowerObserver::OnResume); |
148 } | 160 } |
149 | 161 |
150 void SystemMonitor::BatteryCheck() { | 162 void SystemMonitor::BatteryCheck() { |
151 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 163 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); |
152 } | 164 } |
153 | 165 |
154 } // namespace base | 166 } // namespace base |
OLD | NEW |