Commit 725e31cf authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Update API for recording interaction/decision enums in MetricsHelper

Update RecordSingleDecisionToMetrics and RecordSingleInteractionToMetrics
to use a simpler API, which now supports non-constant histogram names.

Change-Id: Iae63351d0ce6915841f48b614aad7a22f12839ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347319Reviewed-by: default avatarCarlos IL <carlosil@chromium.org>
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796979}
parent 39236c8e
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "components/history/core/browser/history_service.h"
......@@ -21,25 +22,16 @@ namespace security_interstitials {
namespace {
// Directly adds to the UMA histograms, using the same properties as
// UMA_HISTOGRAM_ENUMERATION, because the macro doesn't allow non-constant
// histogram names.
void RecordSingleDecisionToMetrics(MetricsHelper::Decision decision,
const std::string& histogram_name) {
base::HistogramBase* histogram = base::LinearHistogram::FactoryGet(
histogram_name, 1, MetricsHelper::MAX_DECISION,
MetricsHelper::MAX_DECISION + 1,
base::HistogramBase::kUmaTargetedHistogramFlag);
histogram->Add(decision);
base::UmaHistogramExactLinear(histogram_name, decision,
MetricsHelper::MAX_DECISION);
}
void RecordSingleInteractionToMetrics(MetricsHelper::Interaction interaction,
const std::string& histogram_name) {
base::HistogramBase* histogram = base::LinearHistogram::FactoryGet(
histogram_name, 1, MetricsHelper::MAX_INTERACTION,
MetricsHelper::MAX_INTERACTION + 1,
base::HistogramBase::kUmaTargetedHistogramFlag);
histogram->Add(interaction);
base::UmaHistogramExactLinear(histogram_name, interaction,
MetricsHelper::MAX_INTERACTION);
}
void MaybeRecordDecisionAsAction(MetricsHelper::Decision decision,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment