Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome/browser/chromeos/resource_reporter/resource_reporter.h

Issue 2510803003: Pass RapporService to content/browser/ (Closed)
Patch Set: Fix more compile errors in JNI files Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/memory_coordinator_client.h" 16 #include "base/memory/memory_coordinator_client.h"
17 #include "base/memory/memory_pressure_listener.h" 17 #include "base/memory/memory_pressure_listener.h"
18 #include "base/memory/singleton.h" 18 #include "base/memory/singleton.h"
19 #include "chrome/browser/task_manager/task_manager_observer.h" 19 #include "chrome/browser/task_manager/task_manager_observer.h"
20 #include "components/metrics/metrics_service.h" 20 #include "components/metrics/metrics_service.h"
21 #include "components/prefs/pref_registry_simple.h" 21 #include "components/prefs/pref_registry_simple.h"
22 #include "components/rappor/sample.h" 22 #include "components/rappor/public/sample.h"
23 23
24 namespace chromeos { 24 namespace chromeos {
25 25
26 // A system that tracks the top |kTopConsumersCount| CPU and memory consumer 26 // A system that tracks the top |kTopConsumersCount| CPU and memory consumer
27 // Chrome tasks and reports a weighted random sample of them via Rappor whenever 27 // Chrome tasks and reports a weighted random sample of them via Rappor whenever
28 // memory pressure is critical. The reporting is limited to once per 28 // memory pressure is critical. The reporting is limited to once per
29 // |kMinimumTimeBetweenReportsInMS|. 29 // |kMinimumTimeBetweenReportsInMS|.
30 class ResourceReporter : public task_manager::TaskManagerObserver, 30 class ResourceReporter : public task_manager::TaskManagerObserver,
31 public base::MemoryCoordinatorClient { 31 public base::MemoryCoordinatorClient {
32 public: 32 public:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 }; 133 };
134 134
135 // The CPU and memory thresholds beyond which the tasks will be reported. 135 // The CPU and memory thresholds beyond which the tasks will be reported.
136 static const double kTaskCpuThresholdForReporting; 136 static const double kTaskCpuThresholdForReporting;
137 static const int64_t kTaskMemoryThresholdForReporting; 137 static const int64_t kTaskMemoryThresholdForReporting;
138 138
139 ResourceReporter(); 139 ResourceReporter();
140 140
141 // Creates a Rappor sample for the given |task_record|. 141 // Creates a Rappor sample for the given |task_record|.
142 static std::unique_ptr<rappor::Sample> CreateRapporSample( 142 static std::unique_ptr<rappor::Sample> CreateRapporSample(
143 rappor::RapporService* rappor_service, 143 rappor::RapporServiceImpl* rappor_service,
144 const TaskRecord& task_record); 144 const TaskRecord& task_record);
145 145
146 // Gets the CPU/memory usage ranges given the |cpu| / |memory_in_bytes| 146 // Gets the CPU/memory usage ranges given the |cpu| / |memory_in_bytes|
147 // values. 147 // values.
148 static CpuUsageRange GetCpuUsageRange(double cpu); 148 static CpuUsageRange GetCpuUsageRange(double cpu);
149 static MemoryUsageRange GetMemoryUsageRange(int64_t memory_in_bytes); 149 static MemoryUsageRange GetMemoryUsageRange(int64_t memory_in_bytes);
150 150
151 // Gets the bucket in which the current system's number of CPU cores fall. 151 // Gets the bucket in which the current system's number of CPU cores fall.
152 static CpuCoresNumberRange GetCurrentSystemCpuCoresRange(); 152 static CpuCoresNumberRange GetCurrentSystemCpuCoresRange();
153 153
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 // Tracks whether monitoring started or not. 194 // Tracks whether monitoring started or not.
195 bool is_monitoring_; 195 bool is_monitoring_;
196 196
197 DISALLOW_COPY_AND_ASSIGN(ResourceReporter); 197 DISALLOW_COPY_AND_ASSIGN(ResourceReporter);
198 }; 198 };
199 199
200 } // namespace chromeos 200 } // namespace chromeos
201 201
202 #endif // CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_ 202 #endif // CHROME_BROWSER_CHROMEOS_RESOURCE_REPORTER_RESOURCE_REPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698