Bug 1357682 - Part 1, helper function for keyed categorical histogram. r=gfritzsche

Create AccumulateCategoricalKeyed() to specify both key and value for the categorical histogram,
sinc AccumulateCategorical() only support non-keyed histogram.

MozReview-Commit-ID: qYMnL9P6Ik

--HG--
extra : rebase_source : 446543601e9234da25d292018d8a6e8a7ac7ba22
This commit is contained in:
Shih-Chiang Chien 2017-07-11 16:51:07 +08:00
Родитель ebbb3689a4
Коммит 36156c3e82
1 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -112,6 +112,23 @@ void AccumulateCategorical(E enumValue) {
static_cast<uint32_t>(enumValue));
};
/**
* Adds sample to a keyed categorical histogram defined in TelemetryHistogramEnums.h
* This is the typesafe - and preferred - way to use the keyed categorical histograms
* by passing values from the corresponding Telemetry::LABELS_* enum.
*
* @param key - the string key
* @param enumValue - Label value from one of the Telemetry::LABELS_* enums.
*/
template<class E>
void AccumulateCategoricalKeyed(const nsCString& key, E enumValue) {
static_assert(IsCategoricalLabelEnum<E>::value,
"Only categorical label enum types are supported.");
Accumulate(static_cast<HistogramID>(CategoricalLabelId<E>::value),
key,
static_cast<uint32_t>(enumValue));
};
/**
* Adds sample to a categorical histogram defined in TelemetryHistogramEnums.h
* This string will be matched against the labels defined in Histograms.json.