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 std::string& name, | |
87 const FilePath& path) { | |
88 NotifyDevicesChanged(); | |
tpayne
2012/02/08 16:20:30
At least on windows, this will end up getting call
vandebo (ex-Chrome)
2012/02/08 18:37:01
Yea, I realized that on my drive home. Maybe we s
| |
89 NotifyMediaDeviceAttached(name, path); | |
90 } | |
91 | |
92 void SystemMonitor::ProcessMediaDeviceDetached(const std::string& name) { | |
93 NotifyDevicesChanged(); | |
94 NotifyMediaDeviceDetached(name); | |
95 } | |
96 | |
86 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { | 97 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { |
87 power_observer_list_->AddObserver(obs); | 98 power_observer_list_->AddObserver(obs); |
88 } | 99 } |
89 | 100 |
90 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { | 101 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { |
91 power_observer_list_->RemoveObserver(obs); | 102 power_observer_list_->RemoveObserver(obs); |
92 } | 103 } |
93 | 104 |
94 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { | 105 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { |
95 devices_changed_observer_list_->AddObserver(obs); | 106 devices_changed_observer_list_->AddObserver(obs); |
96 } | 107 } |
97 | 108 |
98 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { | 109 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { |
99 devices_changed_observer_list_->RemoveObserver(obs); | 110 devices_changed_observer_list_->RemoveObserver(obs); |
100 } | 111 } |
101 | 112 |
102 void SystemMonitor::NotifyDevicesChanged() { | 113 void SystemMonitor::NotifyDevicesChanged() { |
103 DVLOG(1) << "DevicesChanged"; | 114 DVLOG(1) << "DevicesChanged"; |
104 devices_changed_observer_list_->Notify( | 115 devices_changed_observer_list_->Notify( |
105 &DevicesChangedObserver::OnDevicesChanged); | 116 &DevicesChangedObserver::OnDevicesChanged); |
106 } | 117 } |
107 | 118 |
119 void SystemMonitor::NotifyMediaDeviceAttached(const std::string& name, | |
120 const FilePath& path) { | |
121 devices_changed_observer_list_->Notify( | |
122 &DevicesChangedObserver::OnMediaDeviceAttached, name, path); | |
123 } | |
124 | |
125 void SystemMonitor::NotifyMediaDeviceDetached(const std::string& name) { | |
126 devices_changed_observer_list_->Notify( | |
127 &DevicesChangedObserver::OnMediaDeviceDetached, name); | |
128 } | |
129 | |
108 void SystemMonitor::NotifyPowerStateChange() { | 130 void SystemMonitor::NotifyPowerStateChange() { |
109 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") | 131 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") |
110 << " battery"; | 132 << " battery"; |
111 power_observer_list_->Notify(&PowerObserver::OnPowerStateChange, | 133 power_observer_list_->Notify(&PowerObserver::OnPowerStateChange, |
112 BatteryPower()); | 134 BatteryPower()); |
113 } | 135 } |
114 | 136 |
115 void SystemMonitor::NotifySuspend() { | 137 void SystemMonitor::NotifySuspend() { |
116 DVLOG(1) << "Power Suspending"; | 138 DVLOG(1) << "Power Suspending"; |
117 power_observer_list_->Notify(&PowerObserver::OnSuspend); | 139 power_observer_list_->Notify(&PowerObserver::OnSuspend); |
118 } | 140 } |
119 | 141 |
120 void SystemMonitor::NotifyResume() { | 142 void SystemMonitor::NotifyResume() { |
121 DVLOG(1) << "Power Resuming"; | 143 DVLOG(1) << "Power Resuming"; |
122 power_observer_list_->Notify(&PowerObserver::OnResume); | 144 power_observer_list_->Notify(&PowerObserver::OnResume); |
123 } | 145 } |
124 | 146 |
125 void SystemMonitor::BatteryCheck() { | 147 void SystemMonitor::BatteryCheck() { |
126 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 148 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); |
127 } | 149 } |
128 | 150 |
129 } // namespace base | 151 } // namespace base |
OLD | NEW |