Commit 1316c14a authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Added histograms for frames+outcomes of user activation users.

Bug: 897829
Change-Id: Id1ab2eb8c4bc76c1de959e8f229a8a3298bcbc78
TBR: rkaplow@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/1297000
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602299}
parent c92fda64
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/frame/frame.h"
#include "base/test/metrics/histogram_tester.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/user_gesture_indicator.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
......@@ -189,4 +190,33 @@ TEST_F(FrameTest, UserActivationInterfaceTest) {
LocalFrame::ConsumeTransientUserActivation(GetDocument().GetFrame()));
}
TEST_F(FrameTest, UserActivationHistograms) {
RuntimeEnabledFeatures::SetUserActivationV2Enabled(true);
base::HistogramTester histograms;
LocalFrame::HasTransientUserActivation(GetDocument().GetFrame());
histograms.ExpectBucketCount("UserActivation.AvailabilityCheck.FrameResult",
0, 1);
LocalFrame::ConsumeTransientUserActivation(GetDocument().GetFrame());
histograms.ExpectBucketCount("UserActivation.Consumption.FrameResult", 0, 1);
LocalFrame::NotifyUserActivation(GetDocument().GetFrame());
LocalFrame::HasTransientUserActivation(GetDocument().GetFrame());
LocalFrame::HasTransientUserActivation(GetDocument().GetFrame());
histograms.ExpectBucketCount("UserActivation.AvailabilityCheck.FrameResult",
3, 2);
LocalFrame::ConsumeTransientUserActivation(GetDocument().GetFrame());
histograms.ExpectBucketCount("UserActivation.Consumption.FrameResult", 3, 1);
LocalFrame::ConsumeTransientUserActivation(GetDocument().GetFrame());
histograms.ExpectBucketCount("UserActivation.Consumption.FrameResult", 0, 2);
histograms.ExpectTotalCount("UserActivation.AvailabilityCheck.FrameResult",
3);
histograms.ExpectTotalCount("UserActivation.Consumption.FrameResult", 3);
}
} // namespace blink
......@@ -1463,10 +1463,45 @@ void LocalFrame::DeprecatedReportFeaturePolicyViolation(
GetSecurityContext()->ReportFeaturePolicyViolation(feature);
}
namespace {
LocalFrame* user_activation_notifier_frame_ = nullptr;
enum UserActivationFrameResultEnum {
kNullFailure = 0,
kNullSuccess = 1,
kSelfFailure = 2,
kSelfSuccess = 3,
kAncestorFailure = 4,
kAncestorSuccess = 5,
kDescendantFailure = 6,
kDescendantSuccess = 7,
kOtherFailure = 8,
kOtherSuccess = 9,
kMaxValue = kOtherSuccess
};
UserActivationFrameResultEnum determineFrameResultEnum(
const LocalFrame* const caller_frame,
const bool call_succeeded) {
if (!caller_frame || !user_activation_notifier_frame_)
return call_succeeded ? kNullSuccess : kNullFailure;
if (caller_frame == user_activation_notifier_frame_)
return call_succeeded ? kSelfSuccess : kSelfFailure;
if (user_activation_notifier_frame_->Tree().IsDescendantOf(caller_frame))
return call_succeeded ? kAncestorSuccess : kAncestorFailure;
if (caller_frame->Tree().IsDescendantOf(user_activation_notifier_frame_))
return call_succeeded ? kDescendantSuccess : kDescendantFailure;
return call_succeeded ? kOtherSuccess : kOtherFailure;
}
} // namespace
// static
std::unique_ptr<UserGestureIndicator> LocalFrame::NotifyUserActivation(
LocalFrame* frame,
UserGestureToken::Status status) {
user_activation_notifier_frame_ = frame;
if (frame)
frame->NotifyUserActivation();
return std::make_unique<UserGestureIndicator>(status);
......@@ -1477,6 +1512,7 @@ std::unique_ptr<UserGestureIndicator> LocalFrame::NotifyUserActivation(
LocalFrame* frame,
UserGestureToken* token) {
DCHECK(!RuntimeEnabledFeatures::UserActivationV2Enabled());
user_activation_notifier_frame_ = frame;
if (frame)
frame->NotifyUserActivation();
return std::make_unique<UserGestureIndicator>(token);
......@@ -1485,13 +1521,19 @@ std::unique_ptr<UserGestureIndicator> LocalFrame::NotifyUserActivation(
// static
bool LocalFrame::HasTransientUserActivation(LocalFrame* frame,
bool check_if_main_thread) {
bool available;
if (RuntimeEnabledFeatures::UserActivationV2Enabled()) {
return frame ? frame->HasTransientUserActivation() : false;
available = frame ? frame->HasTransientUserActivation() : false;
} else {
available = check_if_main_thread
? UserGestureIndicator::ProcessingUserGestureThreadSafe()
: UserGestureIndicator::ProcessingUserGesture();
}
return check_if_main_thread
? UserGestureIndicator::ProcessingUserGestureThreadSafe()
: UserGestureIndicator::ProcessingUserGesture();
UMA_HISTOGRAM_ENUMERATION("UserActivation.AvailabilityCheck.FrameResult",
determineFrameResultEnum(frame, available));
return available;
}
// static
......@@ -1499,13 +1541,21 @@ bool LocalFrame::ConsumeTransientUserActivation(
LocalFrame* frame,
bool check_if_main_thread,
UserActivationUpdateSource update_source) {
bool consumed;
if (RuntimeEnabledFeatures::UserActivationV2Enabled()) {
return frame ? frame->ConsumeTransientUserActivation(update_source) : false;
consumed =
frame ? frame->ConsumeTransientUserActivation(update_source) : false;
} else {
consumed = check_if_main_thread
? UserGestureIndicator::ConsumeUserGestureThreadSafe()
: UserGestureIndicator::ConsumeUserGesture();
}
return check_if_main_thread
? UserGestureIndicator::ConsumeUserGestureThreadSafe()
: UserGestureIndicator::ConsumeUserGesture();
UMA_HISTOGRAM_ENUMERATION("UserActivation.Consumption.FrameResult",
determineFrameResultEnum(frame, consumed));
user_activation_notifier_frame_ = nullptr;
return consumed;
}
void LocalFrame::NotifyUserActivation() {
......
......@@ -50495,6 +50495,19 @@ Full version information for the fingerprint enum values:
<int value="0" label="Used Omnibox"/>
</enum>
<enum name="UserActivationFrameResultEnum">
<int value="0" label="NullFailure"/>
<int value="1" label="NullSuccess"/>
<int value="2" label="SelfFailure"/>
<int value="3" label="SelfSuccess"/>
<int value="4" label="AncestorFailure"/>
<int value="5" label="AncestorSuccess"/>
<int value="6" label="DescendantFailure"/>
<int value="7" label="DescendantSuccess"/>
<int value="8" label="OtherFailure"/>
<int value="9" label="OtherSuccess"/>
</enum>
<enum name="UserCertContentDisposition">
<int value="0" label="No Content-Disposition"/>
<int value="1" label="Content-Disposition"/>
......@@ -114010,6 +114010,24 @@ uploading your change for review.
</summary>
</histogram>
<histogram name="UserActivation.AvailabilityCheck.FrameResult"
enum="UserActivationFrameResultEnum">
<owner>mustaq@chromium.org</owner>
<summary>
Outcomes (success/failure) of transient user activation availability check
attempts for each type of caller frame (null, ancestor, descedant, other).
</summary>
</histogram>
<histogram name="UserActivation.Consumption.FrameResult"
enum="UserActivationFrameResultEnum">
<owner>mustaq@chromium.org</owner>
<summary>
Outcomes (success/failure) of user activation consumption attempts for each
type of caller frame (null, ancestor, descedant, other).
</summary>
</histogram>
<histogram name="UserCert.ContentDisposition" enum="UserCertContentDisposition">
<obsolete>
Removed in M57.
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