Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/metrics/sparse_histogram.h" | |
| 6 | |
| 7 #include "base/metrics/statistics_recorder.h" | |
| 8 #include "base/synchronization/lock.h" | |
| 9 | |
| 10 using std::string; | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: This sort of using statement is not permitted
kaiwang
2012/08/08 03:59:33
are you sure about this?
This is allowed in google
Ilya Sherman
2012/08/08 05:00:29
Sorry, you're right, this sort of using statement
| |
| 11 | |
| 12 namespace base { | |
| 13 | |
| 14 // static | |
| 15 HistogramBase* SparseHistogram::FactoryGet(const string& name, | |
| 16 Flags flags) { | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: Should this be |int32 flags|, as it is everyw
kaiwang
2012/08/08 03:59:33
Done. Good catch
| |
| 17 HistogramBase* histogram = new SparseHistogram(name); | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: I believe this is an intentional leak, right?
| |
| 18 histogram->SetFlags(flags); | |
| 19 return histogram; | |
| 20 } | |
|
Ilya Sherman
2012/08/04 01:18:35
Is this method eventually going to look up the his
kaiwang
2012/08/08 03:59:33
You are right. FactoryGet will eventually register
| |
| 21 | |
| 22 SparseHistogram::~SparseHistogram() {} | |
| 23 | |
| 24 void SparseHistogram::Add(Sample value) { | |
| 25 base::AutoLock auto_lock(*lock_); | |
| 26 sample_[value]++; | |
| 27 } | |
| 28 | |
| 29 void SparseHistogram::SnapshotSample( | |
| 30 SparseHistogram::SampleCounts* sample) const { | |
| 31 base::AutoLock auto_lock(*lock_); | |
| 32 *sample = sample_; | |
| 33 } | |
| 34 | |
| 35 void SparseHistogram::WriteHTMLGraph(string* output) const { | |
|
Ilya Sherman
2012/08/04 01:18:35
nit: Please add a TODO, linked to a crbug, to impl
kaiwang
2012/08/08 03:59:33
Added todo.
Most code is in histogram.cc. Seems no
| |
| 36 } | |
| 37 | |
| 38 void SparseHistogram::WriteAscii(string* output) const { | |
| 39 } | |
| 40 | |
| 41 SparseHistogram::SparseHistogram(const string& name) | |
| 42 : HistogramBase(name), | |
| 43 lock_(new base::Lock()) {} | |
| 44 | |
| 45 } // namespace base | |
| OLD | NEW |