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