| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 NOTIFICATION_RENDERER_PROCESS_CREATED, | 129 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 130 NotificationService::AllBrowserContextsAndSources()); | 130 NotificationService::AllBrowserContextsAndSources()); |
| 131 registrar_.Add(this, | 131 registrar_.Add(this, |
| 132 NOTIFICATION_RENDERER_PROCESS_CLOSED, | 132 NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 133 NotificationService::AllBrowserContextsAndSources()); | 133 NotificationService::AllBrowserContextsAndSources()); |
| 134 subscription_ = | 134 subscription_ = |
| 135 device::BatteryStatusService::GetInstance()->AddCallback(callback_); | 135 device::BatteryStatusService::GetInstance()->AddCallback(callback_); |
| 136 | 136 |
| 137 // Delay initialization until the system has been up for a while. | 137 // Delay initialization until the system has been up for a while. |
| 138 // This is to mitigate the effect of increased power draw during system start. | 138 // This is to mitigate the effect of increased power draw during system start. |
| 139 base::TimeDelta uptime = | 139 base::TimeDelta uptime = base::SysInfo::Uptime(); |
| 140 base::TimeDelta::FromMilliseconds(base::SysInfo::Uptime()); | |
| 141 base::TimeDelta min_uptime = base::TimeDelta::FromMinutes(kMinUptimeMinutes); | 140 base::TimeDelta min_uptime = base::TimeDelta::FromMinutes(kMinUptimeMinutes); |
| 142 if (uptime < min_uptime) { | 141 if (uptime < min_uptime) { |
| 143 base::TimeDelta delay = min_uptime - uptime; | 142 base::TimeDelta delay = min_uptime - uptime; |
| 144 BrowserThread::PostDelayedTask( | 143 BrowserThread::PostDelayedTask( |
| 145 BrowserThread::UI, | 144 BrowserThread::UI, |
| 146 FROM_HERE, | 145 FROM_HERE, |
| 147 base::Bind(&PowerUsageMonitor::StartInternal, base::Unretained(this)), | 146 base::Bind(&PowerUsageMonitor::StartInternal, base::Unretained(this)), |
| 148 delay); | 147 delay); |
| 149 } else { | 148 } else { |
| 150 StartInternal(); | 149 StartInternal(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 266 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
| 268 OnRenderProcessNotification(type, rph->GetID()); | 267 OnRenderProcessNotification(type, rph->GetID()); |
| 269 } | 268 } |
| 270 | 269 |
| 271 void PowerUsageMonitor::CancelPendingHistogramReporting() { | 270 void PowerUsageMonitor::CancelPendingHistogramReporting() { |
| 272 // Cancel any in-progress histogram reports and reporting of discharge UMA. | 271 // Cancel any in-progress histogram reports and reporting of discharge UMA. |
| 273 system_interface_->CancelPendingHistogramReports(); | 272 system_interface_->CancelPendingHistogramReports(); |
| 274 } | 273 } |
| 275 | 274 |
| 276 } // namespace content | 275 } // namespace content |
| OLD | NEW |