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