Commit d81353f5 authored by Takumi Fujimoto's avatar Takumi Fujimoto Committed by Commit Bot

[Media Router WebUI] Add a UMA metric to record sink search outcome

Add a boolean metric MediaRouter.Sink.SearchOutcome, which records
whether or not a sink was found for the ID that the user entered and
attempted to cast to.

Bug: 867086
Change-Id: Ie1bf8072b7700298b8a783480b05a2e845666946
Reviewed-on: https://chromium-review.googlesource.com/1148956Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578721}
parent b5ba0108
......@@ -61,6 +61,8 @@ const char MediaRouterMetrics::kHistogramMediaSinkType[] =
"MediaRouter.Sink.SelectedType";
const char MediaRouterMetrics::kHistogramPresentationUrlType[] =
"MediaRouter.PresentationRequest.AvailabilityUrlType";
const char MediaRouterMetrics::kHistogramRecordSearchSinkOutcome[] =
"MediaRouter.Sink.SearchOutcome";
const char MediaRouterMetrics::kHistogramRouteCreationOutcome[] =
"MediaRouter.Route.CreationOutcome";
const char MediaRouterMetrics::kHistogramStartLocalLatency[] =
......@@ -187,4 +189,9 @@ void MediaRouterMetrics::RecordStartLocalSessionSuccessful(bool success) {
UMA_HISTOGRAM_BOOLEAN(kHistogramStartLocalSessionSuccessful, success);
}
// static
void MediaRouterMetrics::RecordSearchSinkOutcome(bool success) {
UMA_HISTOGRAM_BOOLEAN(kHistogramRecordSearchSinkOutcome, success);
}
} // namespace media_router
......@@ -89,6 +89,7 @@ class MediaRouterMetrics {
static const char kHistogramMediaRouterFileSize[];
static const char kHistogramMediaSinkType[];
static const char kHistogramPresentationUrlType[];
static const char kHistogramRecordSearchSinkOutcome[];
static const char kHistogramRouteCreationOutcome[];
static const char kHistogramStartLocalLatency[];
static const char kHistogramStartLocalPosition[];
......@@ -159,6 +160,10 @@ class MediaRouterMetrics {
// Records whether or not an attempt to start casting was successful.
static void RecordStartLocalSessionSuccessful(bool success);
// Records whether or not a sink was found for the ID that the user manually
// entered and attempted to cast to.
static void RecordSearchSinkOutcome(bool success);
};
} // namespace media_router
......
......@@ -38,6 +38,22 @@ void TestRecordTimeDeltaMetric(
tester.ExpectUniqueSample(histogram_name, delta.InMilliseconds(), 1);
}
// Tests that calling |recording_cb| with boolean values records them in
// |histogram_name|.
void TestRecordBooleanMetric(base::RepeatingCallback<void(bool)> recording_cb,
const std::string& histogram_name) {
base::HistogramTester tester;
tester.ExpectTotalCount(histogram_name, 0);
recording_cb.Run(true);
recording_cb.Run(false);
recording_cb.Run(true);
tester.ExpectTotalCount(histogram_name, 3);
EXPECT_THAT(tester.GetAllSamples(histogram_name),
ElementsAre(Bucket(false, 1), Bucket(true, 2)));
}
} // namespace
using DialParsingError = SafeDialDeviceDescriptionParser::ParsingError;
......@@ -237,19 +253,16 @@ TEST(MediaRouterMetricsTest, RecordStartLocalSessionLatency) {
}
TEST(MediaRouterMetricsTest, RecordStartLocalSessionSuccessful) {
base::HistogramTester tester;
tester.ExpectTotalCount(
MediaRouterMetrics::kHistogramStartLocalSessionSuccessful, 0);
MediaRouterMetrics::RecordStartLocalSessionSuccessful(true);
MediaRouterMetrics::RecordStartLocalSessionSuccessful(false);
MediaRouterMetrics::RecordStartLocalSessionSuccessful(true);
TestRecordBooleanMetric(
base::BindRepeating(
&MediaRouterMetrics::RecordStartLocalSessionSuccessful),
MediaRouterMetrics::kHistogramStartLocalSessionSuccessful);
}
tester.ExpectTotalCount(
MediaRouterMetrics::kHistogramStartLocalSessionSuccessful, 3);
EXPECT_THAT(tester.GetAllSamples(
MediaRouterMetrics::kHistogramStartLocalSessionSuccessful),
ElementsAre(Bucket(false, 1), Bucket(true, 2)));
TEST(MediaRouterMetricsTest, RecordSearchSinkOutcome) {
TestRecordBooleanMetric(
base::BindRepeating(&MediaRouterMetrics::RecordSearchSinkOutcome),
MediaRouterMetrics::kHistogramRecordSearchSinkOutcome);
}
} // namespace media_router
......@@ -336,6 +336,7 @@ void MediaRouterUI::OnSearchSinkResponseReceived(
handler_->ReturnSearchResult(found_sink_id);
CreateRoute(found_sink_id, cast_mode);
MediaRouterMetrics::RecordSearchSinkOutcome(!found_sink_id.empty());
}
void MediaRouterUI::InitCommon(content::WebContents* initiator) {
......
......@@ -43220,6 +43220,15 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="MediaRouter.Sink.SearchOutcome" enum="BooleanSuccess">
<owner>takumif@chromium.org</owner>
<summary>
The outcome of querying Media Route Providers for a sink by ID.
&quot;Success&quot; indicates that a sink was found. This is recorded when
the user attempts to cast to a sink with a manually entered ID.
</summary>
</histogram>
<histogram name="MediaRouter.Sink.SelectedType" enum="MediaSinkType">
<owner>takumif@chromium.org</owner>
<summary>
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