Chromium Code Reviews| Index: chrome/browser/chromeos/resource_reporter/resource_reporter.cc |
| diff --git a/chrome/browser/chromeos/resource_reporter/resource_reporter.cc b/chrome/browser/chromeos/resource_reporter/resource_reporter.cc |
| index de550210831cb62a7583d64b2112fc797048eccd..15331c74b98c0136f5e675a97696022b44d58175 100644 |
| --- a/chrome/browser/chromeos/resource_reporter/resource_reporter.cc |
| +++ b/chrome/browser/chromeos/resource_reporter/resource_reporter.cc |
| @@ -72,14 +72,7 @@ constexpr char kLastRapporReportTimeKey[] = |
| constexpr base::TimeDelta kMinimumTimeBetweenReports = |
| base::TimeDelta::FromDays(1); |
| -// Gets the memory usage threshold of a process beyond which the process is |
| -// considered memory-intensive on the current device it's running on. |
| -int64_t GetMemoryThresholdForDeviceInBytes() { |
| - const int64_t bytes_per_cpu = base::SysInfo::AmountOfPhysicalMemory() / |
| - base::SysInfo::NumberOfProcessors(); |
| - |
| - return bytes_per_cpu * 0.6; |
| -} |
| +constexpr double kTaskCpuThresholdForReporting = 70.0; |
| } // namespace |
| @@ -175,8 +168,8 @@ void ResourceReporter::OnTasksRefreshedWithBackgroundCalculations( |
| default: |
| // Other tasks types will be reported using Rappor. |
| - if (memory_usage < kTaskMemoryThresholdForReporting && |
| - cpu_usage < kTaskCpuThresholdForReporting) { |
| + if (memory_usage < GetTaskMemoryThresholdForReporting() && |
| + cpu_usage < GetTaskCpuThresholdForReporting()) { |
| // We only care about CPU and memory intensive tasks. |
| break; |
| } |
| @@ -205,13 +198,6 @@ void ResourceReporter::OnTasksRefreshedWithBackgroundCalculations( |
| base::Bind(&ResourceReporter::ReportSamples, base::Unretained(this))); |
| } |
| -// static |
| -const double ResourceReporter::kTaskCpuThresholdForReporting = 70.0; |
| - |
| -// static |
| -const int64_t ResourceReporter::kTaskMemoryThresholdForReporting = |
|
Lei Zhang
2017/04/07 19:12:43
This constant has to be computed at startup.
|
| - GetMemoryThresholdForDeviceInBytes(); |
| - |
| ResourceReporter::ResourceReporter() |
| : TaskManagerObserver(base::TimeDelta::FromSeconds(kRefreshIntervalSeconds), |
| task_manager::REFRESH_TYPE_CPU | |
| @@ -226,6 +212,19 @@ ResourceReporter::ResourceReporter() |
| is_monitoring_(false) {} |
| // static |
| +double ResourceReporter::GetTaskCpuThresholdForReporting() { |
| + return kTaskCpuThresholdForReporting; |
| +} |
| + |
| +// static |
| +int64_t ResourceReporter::GetTaskMemoryThresholdForReporting() { |
| + static const int64_t threshold = 0.6 * |
|
Lei Zhang
2017/04/07 19:12:43
Now it's computed at first use.
|
| + base::SysInfo::AmountOfPhysicalMemory() / |
| + base::SysInfo::NumberOfProcessors(); |
| + return threshold; |
| +} |
| + |
| +// static |
| std::unique_ptr<rappor::Sample> ResourceReporter::CreateRapporSample( |
| rappor::RapporServiceImpl* rappor_service, |
| const ResourceReporter::TaskRecord& task_record) { |