OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 NotifySuspend(); | 76 NotifySuspend(); |
77 } | 77 } |
78 break; | 78 break; |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 void SystemMonitor::ProcessDevicesChanged() { | 82 void SystemMonitor::ProcessDevicesChanged() { |
83 NotifyDevicesChanged(); | 83 NotifyDevicesChanged(); |
84 } | 84 } |
85 | 85 |
| 86 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id, |
| 87 const std::string& name, |
| 88 const FilePath& path) { |
| 89 NotifyMediaDeviceAttached(id, name, path); |
| 90 } |
| 91 |
| 92 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) { |
| 93 NotifyMediaDeviceDetached(id); |
| 94 } |
| 95 |
86 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { | 96 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { |
87 power_observer_list_->AddObserver(obs); | 97 power_observer_list_->AddObserver(obs); |
88 } | 98 } |
89 | 99 |
90 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { | 100 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { |
91 power_observer_list_->RemoveObserver(obs); | 101 power_observer_list_->RemoveObserver(obs); |
92 } | 102 } |
93 | 103 |
94 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { | 104 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { |
95 devices_changed_observer_list_->AddObserver(obs); | 105 devices_changed_observer_list_->AddObserver(obs); |
96 } | 106 } |
97 | 107 |
98 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { | 108 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { |
99 devices_changed_observer_list_->RemoveObserver(obs); | 109 devices_changed_observer_list_->RemoveObserver(obs); |
100 } | 110 } |
101 | 111 |
102 void SystemMonitor::NotifyDevicesChanged() { | 112 void SystemMonitor::NotifyDevicesChanged() { |
103 DVLOG(1) << "DevicesChanged"; | 113 DVLOG(1) << "DevicesChanged"; |
104 devices_changed_observer_list_->Notify( | 114 devices_changed_observer_list_->Notify( |
105 &DevicesChangedObserver::OnDevicesChanged); | 115 &DevicesChangedObserver::OnDevicesChanged); |
106 } | 116 } |
107 | 117 |
| 118 void SystemMonitor::NotifyMediaDeviceAttached(const DeviceIdType& id, |
| 119 const std::string& name, |
| 120 const FilePath& path) { |
| 121 DVLOG(1) << "MediaDeviceAttached with name " << name << " and id " << id; |
| 122 devices_changed_observer_list_->Notify( |
| 123 &DevicesChangedObserver::OnMediaDeviceAttached, id, name, path); |
| 124 } |
| 125 |
| 126 void SystemMonitor::NotifyMediaDeviceDetached(const DeviceIdType& id) { |
| 127 DVLOG(1) << "MediaDeviceDetached for id " << id; |
| 128 devices_changed_observer_list_->Notify( |
| 129 &DevicesChangedObserver::OnMediaDeviceDetached, id); |
| 130 } |
| 131 |
108 void SystemMonitor::NotifyPowerStateChange() { | 132 void SystemMonitor::NotifyPowerStateChange() { |
109 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") | 133 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") |
110 << " battery"; | 134 << " battery"; |
111 power_observer_list_->Notify(&PowerObserver::OnPowerStateChange, | 135 power_observer_list_->Notify(&PowerObserver::OnPowerStateChange, |
112 BatteryPower()); | 136 BatteryPower()); |
113 } | 137 } |
114 | 138 |
115 void SystemMonitor::NotifySuspend() { | 139 void SystemMonitor::NotifySuspend() { |
116 DVLOG(1) << "Power Suspending"; | 140 DVLOG(1) << "Power Suspending"; |
117 power_observer_list_->Notify(&PowerObserver::OnSuspend); | 141 power_observer_list_->Notify(&PowerObserver::OnSuspend); |
118 } | 142 } |
119 | 143 |
120 void SystemMonitor::NotifyResume() { | 144 void SystemMonitor::NotifyResume() { |
121 DVLOG(1) << "Power Resuming"; | 145 DVLOG(1) << "Power Resuming"; |
122 power_observer_list_->Notify(&PowerObserver::OnResume); | 146 power_observer_list_->Notify(&PowerObserver::OnResume); |
123 } | 147 } |
124 | 148 |
125 void SystemMonitor::BatteryCheck() { | 149 void SystemMonitor::BatteryCheck() { |
126 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 150 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); |
127 } | 151 } |
128 | 152 |
129 } // namespace base | 153 } // namespace base |
OLD | NEW |