| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 break; | 76 break; |
| 77 case SUSPEND_EVENT: | 77 case SUSPEND_EVENT: |
| 78 if (!suspended_) { | 78 if (!suspended_) { |
| 79 suspended_ = true; | 79 suspended_ = true; |
| 80 NotifySuspend(); | 80 NotifySuspend(); |
| 81 } | 81 } |
| 82 break; | 82 break; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SystemMonitor::ProcessDevicesChanged() { | 86 void SystemMonitor::ProcessDevicesChanged(DeviceType device_type) { |
| 87 NotifyDevicesChanged(); | 87 NotifyDevicesChanged(device_type); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SystemMonitor::ProcessMediaDeviceAttached( | 90 void SystemMonitor::ProcessMediaDeviceAttached( |
| 91 const std::string& id, | 91 const std::string& id, |
| 92 const string16& name, | 92 const string16& name, |
| 93 MediaDeviceType type, | 93 MediaDeviceType type, |
| 94 const FilePath::StringType& location) { | 94 const FilePath::StringType& location) { |
| 95 MediaDeviceInfo info(id, name, type, location); | 95 MediaDeviceInfo info(id, name, type, location); |
| 96 if (ContainsKey(media_device_map_, id)) { | 96 if (ContainsKey(media_device_map_, id)) { |
| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 129 } |
| 130 | 130 |
| 131 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { | 131 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { |
| 132 devices_changed_observer_list_->AddObserver(obs); | 132 devices_changed_observer_list_->AddObserver(obs); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { | 135 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { |
| 136 devices_changed_observer_list_->RemoveObserver(obs); | 136 devices_changed_observer_list_->RemoveObserver(obs); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void SystemMonitor::NotifyDevicesChanged() { | 139 void SystemMonitor::NotifyDevicesChanged(DeviceType device_type) { |
| 140 DVLOG(1) << "DevicesChanged"; | 140 DVLOG(1) << "DevicesChanged with device type " << device_type; |
| 141 devices_changed_observer_list_->Notify( | 141 devices_changed_observer_list_->Notify( |
| 142 &DevicesChangedObserver::OnDevicesChanged); | 142 &DevicesChangedObserver::OnDevicesChanged, device_type); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void SystemMonitor::NotifyMediaDeviceAttached( | 145 void SystemMonitor::NotifyMediaDeviceAttached( |
| 146 const std::string& id, | 146 const std::string& id, |
| 147 const string16& name, | 147 const string16& name, |
| 148 MediaDeviceType type, | 148 MediaDeviceType type, |
| 149 const FilePath::StringType& location) { | 149 const FilePath::StringType& location) { |
| 150 DVLOG(1) << "MediaDeviceAttached with name " << UTF16ToUTF8(name) | 150 DVLOG(1) << "MediaDeviceAttached with name " << UTF16ToUTF8(name) |
| 151 << " and id " << id; | 151 << " and id " << id; |
| 152 devices_changed_observer_list_->Notify( | 152 devices_changed_observer_list_->Notify( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 174 void SystemMonitor::NotifyResume() { | 174 void SystemMonitor::NotifyResume() { |
| 175 DVLOG(1) << "Power Resuming"; | 175 DVLOG(1) << "Power Resuming"; |
| 176 power_observer_list_->Notify(&PowerObserver::OnResume); | 176 power_observer_list_->Notify(&PowerObserver::OnResume); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void SystemMonitor::BatteryCheck() { | 179 void SystemMonitor::BatteryCheck() { |
| 180 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 180 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace base | 183 } // namespace base |
| OLD | NEW |