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

Side by Side Diff: base/metrics/sparse_histogram.cc

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 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 | « base/metrics/sparse_histogram.h ('k') | base/metrics/statistics_recorder.h » ('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 #include "base/metrics/sparse_histogram.h" 5 #include "base/metrics/sparse_histogram.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/metrics_hashes.h" 9 #include "base/metrics/metrics_hashes.h"
10 #include "base/metrics/sample_map.h" 10 #include "base/metrics/sample_map.h"
11 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
12 #include "base/pickle.h" 12 #include "base/pickle.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 typedef HistogramBase::Count Count; 18 typedef HistogramBase::Count Count;
19 typedef HistogramBase::Sample Sample; 19 typedef HistogramBase::Sample Sample;
20 20
21 // static 21 // static
22 HistogramBase* SparseHistogram::FactoryGet(const std::string& name, 22 HistogramBase* SparseHistogram::FactoryGet(const std::string& name,
23 int32 flags) { 23 int32_t flags) {
24 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); 24 HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
25 25
26 if (!histogram) { 26 if (!histogram) {
27 // To avoid racy destruction at shutdown, the following will be leaked. 27 // To avoid racy destruction at shutdown, the following will be leaked.
28 HistogramBase* tentative_histogram = new SparseHistogram(name); 28 HistogramBase* tentative_histogram = new SparseHistogram(name);
29 tentative_histogram->SetFlags(flags); 29 tentative_histogram->SetFlags(flags);
30 histogram = 30 histogram =
31 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram); 31 StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
32 } 32 }
33 DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType()); 33 DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 flags &= ~HistogramBase::kIPCSerializationSourceFlag; 117 flags &= ~HistogramBase::kIPCSerializationSourceFlag;
118 118
119 return SparseHistogram::FactoryGet(histogram_name, flags); 119 return SparseHistogram::FactoryGet(histogram_name, flags);
120 } 120 }
121 121
122 void SparseHistogram::GetParameters(DictionaryValue* params) const { 122 void SparseHistogram::GetParameters(DictionaryValue* params) const {
123 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) 123 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
124 } 124 }
125 125
126 void SparseHistogram::GetCountAndBucketData(Count* count, 126 void SparseHistogram::GetCountAndBucketData(Count* count,
127 int64* sum, 127 int64_t* sum,
128 ListValue* buckets) const { 128 ListValue* buckets) const {
129 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.) 129 // TODO(kaiwang): Implement. (See HistogramBase::WriteJSON.)
130 } 130 }
131 131
132 void SparseHistogram::WriteAsciiImpl(bool graph_it, 132 void SparseHistogram::WriteAsciiImpl(bool graph_it,
133 const std::string& newline, 133 const std::string& newline,
134 std::string* output) const { 134 std::string* output) const {
135 // Get a local copy of the data so we are consistent. 135 // Get a local copy of the data so we are consistent.
136 scoped_ptr<HistogramSamples> snapshot = SnapshotSamples(); 136 scoped_ptr<HistogramSamples> snapshot = SnapshotSamples();
137 Count total_count = snapshot->TotalCount(); 137 Count total_count = snapshot->TotalCount();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 std::string* output) const { 186 std::string* output) const {
187 StringAppendF(output, 187 StringAppendF(output,
188 "Histogram: %s recorded %d samples", 188 "Histogram: %s recorded %d samples",
189 histogram_name().c_str(), 189 histogram_name().c_str(),
190 total_count); 190 total_count);
191 if (flags() & ~kHexRangePrintingFlag) 191 if (flags() & ~kHexRangePrintingFlag)
192 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); 192 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag);
193 } 193 }
194 194
195 } // namespace base 195 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/sparse_histogram.h ('k') | base/metrics/statistics_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698