Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/bind.h" | |
| 6 #include "chrome/browser/chromeos/power/cpu_data_collector.h" | |
| 7 #include "chrome/browser/chromeos/power/power_data_collector.h" | |
| 8 | |
| 9 namespace chromeos { | |
| 10 | |
| 11 namespace { | |
| 12 // The CPU data is sampled every |kCpuDataSamplePeriodSec| seconds. | |
| 13 const int kCpuDataSamplePeriodSec = 30 | |
| 14 | |
| 15 // Sequence name for blocking pool sequenced tasks. | |
| 16 const char kCpuDataCollectionSequenceName[] = | |
| 17 "chromeos_power_cpu_data_collector_sequence"; | |
| 18 } | |
| 19 | |
| 20 CpuDataCollector::CpuDataCollector() { | |
| 21 } | |
| 22 | |
| 23 CpuDataCollector::~CpuDataCollector() { | |
| 24 time_.Stop(); | |
|
Daniel Erat
2014/01/30 15:47:51
is this supposed to be timer_? you don't need to s
| |
| 25 } | |
| 26 | |
| 27 void CpuDataCollector::Start() { | |
| 28 timer_.Start(FROM_HERE, | |
| 29 base::TimeDelta::FromSeconds(kCpuDataSamplePeriodSec), | |
| 30 this, | |
| 31 &CpuDataCollector::PostCollectSample); | |
| 32 } | |
| 33 | |
| 34 void CpuDataCollector::Lock() { | |
| 35 } | |
| 36 | |
| 37 void CpuDataCollector::PostCollectSample() { | |
| 38 content::BrowserThread::PostBlockingPoolSequencedTask( | |
|
Daniel Erat
2014/01/30 15:47:51
use PostBlockingPoolTaskAndReply() instead, like i
| |
| 39 kCpuDataCollectionSequenceName, | |
| 40 FROM_HERE, | |
| 41 base::Bind(&CpuDataCollector::CollectSample, base::Unretained(this))); | |
| 42 } | |
| 43 | |
| 44 void CpuDataCollector::CollectSample() { | |
| 45 // Read samples from sysfs | |
| 46 | |
| 47 Lock(); | |
| 48 // Add samples to cpu_idle_state_data_ and cpu_freq_state_data_ | |
| 49 Unlock(); | |
| 50 } | |
| 51 | |
| 52 } // namespace chromeos | |
| OLD | NEW |