| 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 "content/browser/power_usage_monitor_impl.h" | 5 #include "content/browser/power_usage_monitor_impl.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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 if (live_renderer_ids_.empty() && previous_num_live_renderers != 0) { | 243 if (live_renderer_ids_.empty() && previous_num_live_renderers != 0) { |
| 244 // All render processes have died. | 244 // All render processes have died. |
| 245 CancelPendingHistogramReporting(); | 245 CancelPendingHistogramReporting(); |
| 246 tracking_discharge_ = false; | 246 tracking_discharge_ = false; |
| 247 } | 247 } |
| 248 | 248 |
| 249 } | 249 } |
| 250 | 250 |
| 251 void PowerUsageMonitor::SetSystemInterfaceForTest( | 251 void PowerUsageMonitor::SetSystemInterfaceForTest( |
| 252 scoped_ptr<SystemInterface> interface) { | 252 std::unique_ptr<SystemInterface> interface) { |
| 253 system_interface_ = std::move(interface); | 253 system_interface_ = std::move(interface); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void PowerUsageMonitor::OnPowerStateChange(bool on_battery_power) { | 256 void PowerUsageMonitor::OnPowerStateChange(bool on_battery_power) { |
| 257 } | 257 } |
| 258 | 258 |
| 259 void PowerUsageMonitor::OnResume() { | 259 void PowerUsageMonitor::OnResume() { |
| 260 } | 260 } |
| 261 | 261 |
| 262 void PowerUsageMonitor::OnSuspend() { | 262 void PowerUsageMonitor::OnSuspend() { |
| 263 CancelPendingHistogramReporting(); | 263 CancelPendingHistogramReporting(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void PowerUsageMonitor::Observe(int type, | 266 void PowerUsageMonitor::Observe(int type, |
| 267 const NotificationSource& source, | 267 const NotificationSource& source, |
| 268 const NotificationDetails& details) { | 268 const NotificationDetails& details) { |
| 269 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 269 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
| 270 OnRenderProcessNotification(type, rph->GetID()); | 270 OnRenderProcessNotification(type, rph->GetID()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void PowerUsageMonitor::CancelPendingHistogramReporting() { | 273 void PowerUsageMonitor::CancelPendingHistogramReporting() { |
| 274 // Cancel any in-progress histogram reports and reporting of discharge UMA. | 274 // Cancel any in-progress histogram reports and reporting of discharge UMA. |
| 275 system_interface_->CancelPendingHistogramReports(); | 275 system_interface_->CancelPendingHistogramReports(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace content | 278 } // namespace content |
| OLD | NEW |