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

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

Issue 1002103004: NOT FOR REVIEW - Slow Reports Reference Implementation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: JSON serialization. Created 5 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 | « base/metrics/histogram.cc ('k') | base/metrics/histogram_base.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_BASE_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_BASE_H_
6 #define BASE_METRICS_HISTOGRAM_BASE_H_ 6 #define BASE_METRICS_HISTOGRAM_BASE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/base_export.h" 14 #include "base/base_export.h"
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/callback.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 20
20 class Pickle; 21 class Pickle;
21 class PickleIterator; 22 class PickleIterator;
22 23
23 namespace base { 24 namespace base {
24 25
25 class DictionaryValue; 26 class DictionaryValue;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 139
139 // The following methods provide graphical histogram displays. 140 // The following methods provide graphical histogram displays.
140 virtual void WriteHTMLGraph(std::string* output) const = 0; 141 virtual void WriteHTMLGraph(std::string* output) const = 0;
141 virtual void WriteAscii(std::string* output) const = 0; 142 virtual void WriteAscii(std::string* output) const = 0;
142 143
143 // Produce a JSON representation of the histogram. This is implemented with 144 // Produce a JSON representation of the histogram. This is implemented with
144 // the help of GetParameters and GetCountAndBucketData; overwrite them to 145 // the help of GetParameters and GetCountAndBucketData; overwrite them to
145 // customize the output. 146 // customize the output.
146 void WriteJSON(std::string* output) const; 147 void WriteJSON(std::string* output) const;
147 148
149 typedef base::Callback<void(void)> ModifiedCallback;
150 void SetCallback(const ModifiedCallback&);
151
148 protected: 152 protected:
149 // Subclasses should implement this function to make SerializeInfo work. 153 // Subclasses should implement this function to make SerializeInfo work.
150 virtual bool SerializeInfoImpl(Pickle* pickle) const = 0; 154 virtual bool SerializeInfoImpl(Pickle* pickle) const = 0;
151 155
152 // Writes information about the construction parameters in |params|. 156 // Writes information about the construction parameters in |params|.
153 virtual void GetParameters(DictionaryValue* params) const = 0; 157 virtual void GetParameters(DictionaryValue* params) const = 0;
154 158
155 // Writes information about the current (non-empty) buckets and their sample 159 // Writes information about the current (non-empty) buckets and their sample
156 // counts to |buckets|, the total sample count to |count| and the total sum 160 // counts to |buckets|, the total sample count to |count| and the total sum
157 // to |sum|. 161 // to |sum|.
158 virtual void GetCountAndBucketData(Count* count, 162 virtual void GetCountAndBucketData(Count* count,
159 int64* sum, 163 int64* sum,
160 ListValue* buckets) const = 0; 164 ListValue* buckets) const = 0;
161 165
162 //// Produce actual graph (set of blank vs non blank char's) for a bucket. 166 //// Produce actual graph (set of blank vs non blank char's) for a bucket.
163 void WriteAsciiBucketGraph(double current_size, 167 void WriteAsciiBucketGraph(double current_size,
164 double max_size, 168 double max_size,
165 std::string* output) const; 169 std::string* output) const;
166 170
167 // Return a string description of what goes in a given bucket. 171 // Return a string description of what goes in a given bucket.
168 const std::string GetSimpleAsciiBucketRange(Sample sample) const; 172 const std::string GetSimpleAsciiBucketRange(Sample sample) const;
169 173
170 // Write textual description of the bucket contents (relative to histogram). 174 // Write textual description of the bucket contents (relative to histogram).
171 // Output is the count in the buckets, as well as the percentage. 175 // Output is the count in the buckets, as well as the percentage.
172 void WriteAsciiBucketValue(Count current, 176 void WriteAsciiBucketValue(Count current,
173 double scaled_sum, 177 double scaled_sum,
174 std::string* output) const; 178 std::string* output) const;
175 179
180 ModifiedCallback callback_;
181
176 private: 182 private:
177 const std::string histogram_name_; 183 const std::string histogram_name_;
178 int32_t flags_; 184 int32_t flags_;
179 185
180 DISALLOW_COPY_AND_ASSIGN(HistogramBase); 186 DISALLOW_COPY_AND_ASSIGN(HistogramBase);
181 }; 187 };
182 188
183 } // namespace base 189 } // namespace base
184 190
185 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ 191 #endif // BASE_METRICS_HISTOGRAM_BASE_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram.cc ('k') | base/metrics/histogram_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698