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

Side by Side Diff: components/metrics/file_metrics_provider.h

Issue 2658163002: Merge histograms from providers into StatisticsRecorder for display. (Closed)
Patch Set: rebased Created 3 years, 10 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_METRICS_FILE_METRICS_PROVIDER_H_ 5 #ifndef COMPONENTS_METRICS_FILE_METRICS_PROVIDER_H_
6 #define COMPONENTS_METRICS_FILE_METRICS_PROVIDER_H_ 6 #define COMPONENTS_METRICS_FILE_METRICS_PROVIDER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/metrics/statistics_recorder.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "components/metrics/metrics_provider.h" 19 #include "components/metrics/metrics_provider.h"
19 20
20 class PrefRegistrySimple; 21 class PrefRegistrySimple;
21 class PrefService; 22 class PrefService;
22 23
23 namespace base { 24 namespace base {
24 class TaskRunner; 25 class TaskRunner;
25 } 26 }
26 27
27 namespace metrics { 28 namespace metrics {
28 29
29 // FileMetricsProvider gathers and logs histograms written to files on disk. 30 // FileMetricsProvider gathers and logs histograms written to files on disk.
30 // Any number of files can be registered and will be polled once per upload 31 // Any number of files can be registered and will be polled once per upload
31 // cycle (at startup and periodically thereafter -- about every 30 minutes 32 // cycle (at startup and periodically thereafter -- about every 30 minutes
32 // for desktop) for data to send. 33 // for desktop) for data to send.
33 class FileMetricsProvider : public MetricsProvider { 34 class FileMetricsProvider : public MetricsProvider,
35 public base::StatisticsRecorder::HistogramProvider {
34 public: 36 public:
35 enum SourceType { 37 enum SourceType {
36 // "Atomic" files are a collection of histograms that are written 38 // "Atomic" files are a collection of histograms that are written
37 // completely in a single atomic operation (typically a write followed 39 // completely in a single atomic operation (typically a write followed
38 // by an atomic rename) and the file is never updated again except to 40 // by an atomic rename) and the file is never updated again except to
39 // be replaced by a completely new set of histograms. This is the only 41 // be replaced by a completely new set of histograms. This is the only
40 // option that can be used if the file is not writeable by *this* 42 // option that can be used if the file is not writeable by *this*
41 // process. Once the file has been read, an attempt will be made to 43 // process. Once the file has been read, an attempt will be made to
42 // delete it thus providing some measure of safety should different 44 // delete it thus providing some measure of safety should different
43 // instantiations (such as by different users of a system-level install) 45 // instantiations (such as by different users of a system-level install)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 167
166 // Schedules the deletion of a file in the background using the task-runner. 168 // Schedules the deletion of a file in the background using the task-runner.
167 void DeleteFileAsync(const base::FilePath& path); 169 void DeleteFileAsync(const base::FilePath& path);
168 170
169 // Updates the persistent state information to show a source as being read. 171 // Updates the persistent state information to show a source as being read.
170 void RecordSourceAsRead(SourceInfo* source); 172 void RecordSourceAsRead(SourceInfo* source);
171 173
172 // metrics::MetricsDataProvider: 174 // metrics::MetricsDataProvider:
173 void OnDidCreateMetricsLog() override; 175 void OnDidCreateMetricsLog() override;
174 bool HasInitialStabilityMetrics() override; 176 bool HasInitialStabilityMetrics() override;
175 void MergeHistogramDeltas() override;
176 void RecordInitialHistogramSnapshots( 177 void RecordInitialHistogramSnapshots(
177 base::HistogramSnapshotManager* snapshot_manager) override; 178 base::HistogramSnapshotManager* snapshot_manager) override;
178 179
180 // base::StatisticsRecorder::HistogramProvider:
181 void MergeHistogramDeltas() override;
182
179 // A task-runner capable of performing I/O. 183 // A task-runner capable of performing I/O.
180 scoped_refptr<base::TaskRunner> task_runner_; 184 scoped_refptr<base::TaskRunner> task_runner_;
181 185
182 // A list of sources not currently active that need to be checked for changes. 186 // A list of sources not currently active that need to be checked for changes.
183 SourceInfoList sources_to_check_; 187 SourceInfoList sources_to_check_;
184 188
185 // A list of currently active sources to be merged when required. 189 // A list of currently active sources to be merged when required.
186 SourceInfoList sources_mapped_; 190 SourceInfoList sources_mapped_;
187 191
188 // A list of sources for a previous run. These are held separately because 192 // A list of sources for a previous run. These are held separately because
189 // they are not subject to the periodic background checking that handles 193 // they are not subject to the periodic background checking that handles
190 // metrics for the current run. 194 // metrics for the current run.
191 SourceInfoList sources_for_previous_run_; 195 SourceInfoList sources_for_previous_run_;
192 196
193 // The preferences-service used to store persistent state about sources. 197 // The preferences-service used to store persistent state about sources.
194 PrefService* pref_service_; 198 PrefService* pref_service_;
195 199
196 base::ThreadChecker thread_checker_; 200 base::ThreadChecker thread_checker_;
197 base::WeakPtrFactory<FileMetricsProvider> weak_factory_; 201 base::WeakPtrFactory<FileMetricsProvider> weak_factory_;
198 202
199 DISALLOW_COPY_AND_ASSIGN(FileMetricsProvider); 203 DISALLOW_COPY_AND_ASSIGN(FileMetricsProvider);
200 }; 204 };
201 205
202 } // namespace metrics 206 } // namespace metrics
203 207
204 #endif // COMPONENTS_METRICS_FILE_METRICS_PROVIDER_H_ 208 #endif // COMPONENTS_METRICS_FILE_METRICS_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/subprocess_metrics_provider.cc ('k') | components/metrics/file_metrics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698