| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/memory_coordinator_client.h" | 17 #include "base/memory/memory_coordinator_client.h" |
| 17 #include "base/memory/memory_pressure_listener.h" | 18 #include "base/memory/memory_pressure_listener.h" |
| 18 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
| 19 #include "chrome/browser/task_manager/task_manager_observer.h" | 20 #include "chrome/browser/task_manager/task_manager_observer.h" |
| 20 #include "components/metrics/metrics_service.h" | 21 #include "components/metrics/metrics_service.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 RANGE_NA = 0, | 126 RANGE_NA = 0, |
| 126 RANGE_1_CORE = 1 << 0, | 127 RANGE_1_CORE = 1 << 0, |
| 127 RANGE_2_CORES = 1 << 1, | 128 RANGE_2_CORES = 1 << 1, |
| 128 RANGE_3_TO_4_CORES = 1 << 2, | 129 RANGE_3_TO_4_CORES = 1 << 2, |
| 129 RANGE_5_TO_8_CORES = 1 << 3, | 130 RANGE_5_TO_8_CORES = 1 << 3, |
| 130 RANGE_9_TO_16_CORES = 1 << 4, | 131 RANGE_9_TO_16_CORES = 1 << 4, |
| 131 RANGE_ABOVE_16_CORES = 1 << 5, | 132 RANGE_ABOVE_16_CORES = 1 << 5, |
| 132 NUM_RANGES = 7, | 133 NUM_RANGES = 7, |
| 133 }; | 134 }; |
| 134 | 135 |
| 136 ResourceReporter(); |
| 137 |
| 135 // The CPU and memory thresholds beyond which the tasks will be reported. | 138 // The CPU and memory thresholds beyond which the tasks will be reported. |
| 136 static const double kTaskCpuThresholdForReporting; | 139 static double GetTaskCpuThresholdForReporting(); |
| 137 static const int64_t kTaskMemoryThresholdForReporting; | 140 static int64_t GetTaskMemoryThresholdForReporting(); |
| 138 | |
| 139 ResourceReporter(); | |
| 140 | 141 |
| 141 // Creates a Rappor sample for the given |task_record|. | 142 // Creates a Rappor sample for the given |task_record|. |
| 142 static std::unique_ptr<rappor::Sample> CreateRapporSample( | 143 static std::unique_ptr<rappor::Sample> CreateRapporSample( |
| 143 rappor::RapporServiceImpl* rappor_service, | 144 rappor::RapporServiceImpl* rappor_service, |
| 144 const TaskRecord& task_record); | 145 const TaskRecord& task_record); |
| 145 | 146 |
| 146 // Gets the CPU/memory usage ranges given the |cpu| / |memory_in_bytes| | 147 // Gets the CPU/memory usage ranges given the |cpu| / |memory_in_bytes| |
| 147 // values. | 148 // values. |
| 148 static CpuUsageRange GetCpuUsageRange(double cpu); | 149 static CpuUsageRange GetCpuUsageRange(double cpu); |
| 149 static MemoryUsageRange GetMemoryUsageRange(int64_t memory_in_bytes); | 150 static MemoryUsageRange GetMemoryUsageRange(int64_t memory_in_bytes); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 194 |
| 194 // Tracks whether monitoring started or not. | 195 // Tracks whether monitoring started or not. |
| 195 bool is_monitoring_; | 196 bool is_monitoring_; |
| 196 | 197 |
| 197 DISALLOW_COPY_AND_ASSIGN(ResourceReporter); | 198 DISALLOW_COPY_AND_ASSIGN(ResourceReporter); |
| 198 }; | 199 }; |
| 199 | 200 |
| 200 } // namespace chromeos | 201 } // namespace chromeos |
| 201 | 202 |
| 202 #endif // CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ | 203 #endif // CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ |
| OLD | NEW |