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

Side by Side Diff: src/platform/metrics/metrics_library.h

Issue 2049007: Start transition the metrics library to non-static API. Use gmock in tests. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Break down tests to avoid explicit metrics lib mock checkpoints. Created 10 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 | « src/platform/metrics/metrics_daemon_test.cc ('k') | src/platform/metrics/metrics_library.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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 /* 5 /*
6 * metrics_library.h 6 * metrics_library.h
7 * 7 *
8 * Created on: Dec 1, 2009 8 * Created on: Dec 1, 2009
9 * Author: sosa 9 * Author: sosa
10 */ 10 */
11 11
12 #ifndef METRICS_LIBRARY_H_ 12 #ifndef METRICS_LIBRARY_H_
13 #define METRICS_LIBRARY_H_ 13 #define METRICS_LIBRARY_H_
14 14
15 #include <string> 15 #include <string>
16 16
17 // TODO(sosa@chromium.org): Add testing for send methods 17 // TODO(sosa@chromium.org): Add testing for send methods
18 18
19 // Library used to send metrics both Autotest and Chrome. 19 class MetricsLibraryInterface {
20 class MetricsLibrary {
21 public: 20 public:
21 virtual void Init() = 0;
22 virtual bool SendToUMA(const std::string& name, int sample,
23 int min, int max, int nbuckets) = 0;
24 virtual bool SendEnumToUMA(const std::string& name, int sample, int max) = 0;
25 virtual ~MetricsLibraryInterface() {}
26 };
27
28 // Library used to send metrics to both Autotest and Chrome/UMA.
29 class MetricsLibrary : public MetricsLibraryInterface {
30 public:
31 // Initializes the library.
32 void Init();
33
22 // Sends histogram data to Chrome for transport to UMA and returns 34 // Sends histogram data to Chrome for transport to UMA and returns
23 // true on success. This method results in the equivalent of an 35 // true on success. This method results in the equivalent of an
24 // asynchronous non-blocking RPC to UMA_HISTOGRAM_CUSTOM_COUNTS 36 // asynchronous non-blocking RPC to UMA_HISTOGRAM_CUSTOM_COUNTS
25 // inside Chrome (see base/histogram.h). 37 // inside Chrome (see base/histogram.h).
26 // 38 //
27 // |sample| is the sample value to be recorded (|min| <= |sample| < |max|). 39 // |sample| is the sample value to be recorded (|min| <= |sample| < |max|).
28 // |min| is the minimum value of the histogram samples (|min| > 0). 40 // |min| is the minimum value of the histogram samples (|min| > 0).
29 // |max| is the maximum value of the histogram samples. 41 // |max| is the maximum value of the histogram samples.
30 // |nbuckets| is the number of histogram buckets. 42 // |nbuckets| is the number of histogram buckets.
31 // [0,min) is the implicit underflow bucket. 43 // [0,min) is the implicit underflow bucket.
32 // [|max|,infinity) is the implicit overflow bucket. 44 // [|max|,infinity) is the implicit overflow bucket.
45 bool SendToUMA(const std::string& name, int sample,
46 int min, int max, int nbuckets);
47
48 // Deprecated.
33 static bool SendToChrome(const std::string& name, int sample, 49 static bool SendToChrome(const std::string& name, int sample,
34 int min, int max, int nbuckets); 50 int min, int max, int nbuckets);
35 51
36 // Sends linear histogram data to Chrome for transport to UMA and 52 // Sends linear histogram data to Chrome for transport to UMA and
37 // returns true on success. This method results in the equivalent of 53 // returns true on success. This method results in the equivalent of
38 // an asynchronous non-blocking RPC to UMA_HISTOGRAM_ENUMERATION 54 // an asynchronous non-blocking RPC to UMA_HISTOGRAM_ENUMERATION
39 // inside Chrome (see base/histogram.h). 55 // inside Chrome (see base/histogram.h).
40 // 56 //
41 // |sample| is the sample value to be recorded (1 <= |sample| < |max|). 57 // |sample| is the sample value to be recorded (1 <= |sample| < |max|).
42 // |max| is the maximum value of the histogram samples. 58 // |max| is the maximum value of the histogram samples.
43 // 0 is the implicit underflow bucket. 59 // 0 is the implicit underflow bucket.
44 // [|max|,infinity) is the implicit overflow bucket. 60 // [|max|,infinity) is the implicit overflow bucket.
61 bool SendEnumToUMA(const std::string& name, int sample, int max);
62
63 // Deprecated.
45 static bool SendEnumToChrome(const std::string& name, int sample, int max); 64 static bool SendEnumToChrome(const std::string& name, int sample, int max);
46 65
47 // Sends to Autotest and returns true on success. 66 // Sends to Autotest and returns true on success.
48 static bool SendToAutotest(const std::string& name, int value); 67 static bool SendToAutotest(const std::string& name, int value);
49 }; 68 };
50 69
51 #endif /* METRICS_LIBRARY_H_ */ 70 #endif /* METRICS_LIBRARY_H_ */
OLDNEW
« no previous file with comments | « src/platform/metrics/metrics_daemon_test.cc ('k') | src/platform/metrics/metrics_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698