Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | /* |
| 6 | * metrics_library.h |
| 7 | * |
| 8 | * Created on: Dec 1, 2009 |
| 9 | * Author: sosa |
| 10 | */ |
| 11 | |
| 12 | #ifndef METRICS_LIBRARY_H_ |
| 13 | #define METRICS_LIBRARY_H_ |
| 14 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 15 | #include <string> |
| 16 | |
| 17 | // TODO(sosa@chromium.org): Add testing for send methods |
| 18 | |
Darin Petkov | c2526a1 | 2010-04-21 14:24:04 -0700 | [diff] [blame^] | 19 | // Library used to send metrics both Autotest and Chrome. |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 20 | class MetricsLibrary { |
| 21 | public: |
Darin Petkov | c2526a1 | 2010-04-21 14:24:04 -0700 | [diff] [blame^] | 22 | // Sends histogram data to Chrome for transport to UMA and returns |
| 23 | // true on success. This method results in the equivalent of an |
| 24 | // asynchronous non-blocking RPC to UMA_HISTOGRAM_CUSTOM_COUNTS |
| 25 | // inside Chrome (see base/histogram.h). |
| 26 | // |
| 27 | // |sample| is the sample value to be recorded (|min| <= |sample| < |max|). |
| 28 | // |min| is the minimum value of the histogram samples (|min| > 0). |
| 29 | // |max| is the maximum value of the histogram samples. |
| 30 | // |nbuckets| is the number of histogram buckets. |
| 31 | // [0,min) is the implicit underflow bucket. |
| 32 | // [|max|,infinity) is the implicit overflow bucket. |
| 33 | static bool SendToChrome(const std::string& name, int sample, |
| 34 | int min, int max, int nbuckets); |
| 35 | |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 36 | // Sends to Autotest and returns true on success. |
Darin Petkov | c2526a1 | 2010-04-21 14:24:04 -0700 | [diff] [blame^] | 37 | static bool SendToAutotest(const std::string& name, int value); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | #endif /* METRICS_LIBRARY_H_ */ |