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

Side by Side Diff: base/metrics/histogram_snapshot_manager.h

Issue 2871663003: Add concurrency check to HistogramSnapshotManager. (Closed)
Patch Set: disallow copy and assign Created 3 years, 7 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
« no previous file with comments | « no previous file | base/metrics/histogram_snapshot_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
6 #define BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 6 #define BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <atomic>
10 #include <map> 11 #include <map>
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/metrics/histogram_base.h" 17 #include "base/metrics/histogram_base.h"
17 #include "base/threading/thread_checker.h"
18 18
19 namespace base { 19 namespace base {
20 20
21 class HistogramSamples; 21 class HistogramSamples;
22 class HistogramFlattener; 22 class HistogramFlattener;
23 23
24 // HistogramSnapshotManager handles the logistics of gathering up available 24 // HistogramSnapshotManager handles the logistics of gathering up available
25 // histograms for recording either to disk or for transmission (such as from 25 // histograms for recording either to disk or for transmission (such as from
26 // renderer to browser, or from browser to UMA upload). Since histograms can sit 26 // renderer to browser, or from browser to UMA upload). Since histograms can sit
27 // in memory for an extended period of time, and are vulnerable to memory 27 // in memory for an extended period of time, and are vulnerable to memory
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // The set of inconsistencies (flags) already seen for the histogram. 69 // The set of inconsistencies (flags) already seen for the histogram.
70 // See HistogramBase::Inconsistency for values. 70 // See HistogramBase::Inconsistency for values.
71 uint32_t inconsistencies = 0; 71 uint32_t inconsistencies = 0;
72 }; 72 };
73 73
74 // Capture and hold samples from a histogram. This does all the heavy 74 // Capture and hold samples from a histogram. This does all the heavy
75 // lifting for PrepareDelta() and PrepareAbsolute(). 75 // lifting for PrepareDelta() and PrepareAbsolute().
76 void PrepareSamples(const HistogramBase* histogram, 76 void PrepareSamples(const HistogramBase* histogram,
77 std::unique_ptr<HistogramSamples> samples); 77 std::unique_ptr<HistogramSamples> samples);
78 78
79 // |histogram_flattener_| handles the logistics of recording the histogram
80 // deltas.
81 HistogramFlattener* const histogram_flattener_; // Weak.
82
79 // For histograms, track what has been previously seen, indexed 83 // For histograms, track what has been previously seen, indexed
80 // by the hash of the histogram name. 84 // by the hash of the histogram name.
81 std::map<uint64_t, SampleInfo> known_histograms_; 85 std::map<uint64_t, SampleInfo> known_histograms_;
82 86
83 // |histogram_flattener_| handles the logistics of recording the histogram 87 // A flag indicating if a thread is currently doing an operation. This is
84 // deltas. 88 // used to check against concurrent access which is not supported. A Thread-
85 HistogramFlattener* histogram_flattener_; // Weak. 89 // Checker is not sufficient because it may be guarded by at outside lock
86 90 // (as is the case with cronet).
87 ThreadChecker thread_checker_; 91 std::atomic<bool> is_active_;
88 92
89 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager); 93 DISALLOW_COPY_AND_ASSIGN(HistogramSnapshotManager);
90 }; 94 };
91 95
92 } // namespace base 96 } // namespace base
93 97
94 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_ 98 #endif // BASE_METRICS_HISTOGRAM_SNAPSHOT_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | base/metrics/histogram_snapshot_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698