OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/power_usage_monitor/power_usage_monitor.h" | 5 #include "chrome/browser/power_usage_monitor/power_usage_monitor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 if (live_renderer_ids_.empty() && previous_num_live_renderers != 0) { | 223 if (live_renderer_ids_.empty() && previous_num_live_renderers != 0) { |
224 // All render processes have died. | 224 // All render processes have died. |
225 CancelPendingHistogramReporting(); | 225 CancelPendingHistogramReporting(); |
226 tracking_discharge_ = false; | 226 tracking_discharge_ = false; |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 void PowerUsageMonitor::SetSystemInterfaceForTest( | 230 void PowerUsageMonitor::SetSystemInterfaceForTest( |
231 std::unique_ptr<SystemInterface> interface) { | 231 std::unique_ptr<SystemInterface> system_interface) { |
232 system_interface_ = std::move(interface); | 232 system_interface_ = std::move(system_interface); |
233 } | 233 } |
234 | 234 |
235 void PowerUsageMonitor::OnPowerStateChange(bool on_battery_power) {} | 235 void PowerUsageMonitor::OnPowerStateChange(bool on_battery_power) {} |
236 | 236 |
237 void PowerUsageMonitor::OnResume() {} | 237 void PowerUsageMonitor::OnResume() {} |
238 | 238 |
239 void PowerUsageMonitor::OnSuspend() { | 239 void PowerUsageMonitor::OnSuspend() { |
240 CancelPendingHistogramReporting(); | 240 CancelPendingHistogramReporting(); |
241 } | 241 } |
242 | 242 |
243 void PowerUsageMonitor::Observe(int type, | 243 void PowerUsageMonitor::Observe(int type, |
244 const content::NotificationSource& source, | 244 const content::NotificationSource& source, |
245 const content::NotificationDetails& details) { | 245 const content::NotificationDetails& details) { |
246 content::RenderProcessHost* rph = | 246 content::RenderProcessHost* rph = |
247 content::Source<content::RenderProcessHost>(source).ptr(); | 247 content::Source<content::RenderProcessHost>(source).ptr(); |
248 OnRenderProcessNotification(type, rph->GetID()); | 248 OnRenderProcessNotification(type, rph->GetID()); |
249 } | 249 } |
250 | 250 |
251 void PowerUsageMonitor::CancelPendingHistogramReporting() { | 251 void PowerUsageMonitor::CancelPendingHistogramReporting() { |
252 // Cancel any in-progress histogram reports and reporting of discharge UMA. | 252 // Cancel any in-progress histogram reports and reporting of discharge UMA. |
253 system_interface_->CancelPendingHistogramReports(); | 253 system_interface_->CancelPendingHistogramReports(); |
254 } | 254 } |
OLD | NEW |