Commit 47fec974 authored by mlamouri's avatar mlamouri Committed by Commit bot

Media: add metrics for orientation lock when video goes fullscreen.

This is recording how often the metadata are already available/needed
and the result of the lock attempt.

BUG=670455
R=asvitkine@chromium.org, zqzhang@chromium.org

Review-Url: https://codereview.chromium.org/2581603003
Cr-Commit-Position: refs/heads/master@{#438958}
parent 027b5c96
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "core/frame/ScreenOrientationController.h" #include "core/frame/ScreenOrientationController.h"
#include "core/html/HTMLVideoElement.h" #include "core/html/HTMLVideoElement.h"
#include "core/page/ChromeClient.h" #include "core/page/ChromeClient.h"
#include "platform/Histogram.h"
#include "public/platform/WebScreenInfo.h" #include "public/platform/WebScreenInfo.h"
#include "public/platform/modules/screen_orientation/WebLockOrientationCallback.h" #include "public/platform/modules/screen_orientation/WebLockOrientationCallback.h"
...@@ -15,6 +16,41 @@ namespace blink { ...@@ -15,6 +16,41 @@ namespace blink {
namespace { namespace {
// These values are used for histograms. Do not reorder.
enum class MetadataAvailabilityMetrics {
Available = 0, // Available when lock was attempted.
Missing = 1, // Missing when lock was attempted.
Received = 2, // Received after being missing in order to lock.
// Keep at the end.
Max = 3
};
// These values are used for histograms. Do not reorder.
enum class LockResultMetrics {
AlreadyLocked = 0, // Frame already has a lock.
Portrait = 1, // Locked to portrait.
Landscape = 2, // Locked to landscape.
// Keep at the end.
Max = 3
};
void recordMetadataAvailability(MetadataAvailabilityMetrics metrics) {
DEFINE_STATIC_LOCAL(
EnumerationHistogram, metadataHistogram,
("Media.Video.FullscreenOrientationLock.MetadataAvailability",
static_cast<int>(MetadataAvailabilityMetrics::Max)));
metadataHistogram.count(static_cast<int>(metrics));
}
void recordLockResult(LockResultMetrics metrics) {
DEFINE_STATIC_LOCAL(EnumerationHistogram, lockResultHistogram,
("Media.Video.FullscreenOrientationLock.LockResult",
static_cast<int>(LockResultMetrics::Max)));
lockResultHistogram.count(static_cast<int>(metrics));
}
// WebLockOrientationCallback implementation that will not react to a success // WebLockOrientationCallback implementation that will not react to a success
// nor a failure. // nor a failure.
class DummyScreenOrientationCallback : public WebLockOrientationCallback { class DummyScreenOrientationCallback : public WebLockOrientationCallback {
...@@ -43,22 +79,36 @@ void MediaControlsOrientationLockDelegate::maybeLockOrientation() { ...@@ -43,22 +79,36 @@ void MediaControlsOrientationLockDelegate::maybeLockOrientation() {
DCHECK(m_state != State::MaybeLockedFullscreen); DCHECK(m_state != State::MaybeLockedFullscreen);
if (videoElement().getReadyState() == HTMLMediaElement::kHaveNothing) { if (videoElement().getReadyState() == HTMLMediaElement::kHaveNothing) {
recordMetadataAvailability(MetadataAvailabilityMetrics::Missing);
m_state = State::PendingMetadata; m_state = State::PendingMetadata;
return; return;
} }
if (m_state == State::PendingMetadata)
recordMetadataAvailability(MetadataAvailabilityMetrics::Received);
else
recordMetadataAvailability(MetadataAvailabilityMetrics::Available);
m_state = State::MaybeLockedFullscreen; m_state = State::MaybeLockedFullscreen;
if (!document().frame()) if (!document().frame())
return; return;
auto controller = ScreenOrientationController::from(*document().frame()); auto controller = ScreenOrientationController::from(*document().frame());
if (controller->maybeHasActiveLock()) if (controller->maybeHasActiveLock()) {
recordLockResult(LockResultMetrics::AlreadyLocked);
return; return;
}
controller->lock(computeOrientationLock(), WebScreenOrientationLockType orientationLock = computeOrientationLock();
controller->lock(orientationLock,
WTF::wrapUnique(new DummyScreenOrientationCallback)); WTF::wrapUnique(new DummyScreenOrientationCallback));
m_shouldUnlockOrientation = true; m_shouldUnlockOrientation = true;
if (orientationLock == WebScreenOrientationLockLandscape)
recordLockResult(LockResultMetrics::Landscape);
else
recordLockResult(LockResultMetrics::Portrait);
} }
void MediaControlsOrientationLockDelegate::maybeUnlockOrientation() { void MediaControlsOrientationLockDelegate::maybeUnlockOrientation() {
......
...@@ -25579,6 +25579,23 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -25579,6 +25579,23 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Media.Video.FullscreenOrientationLock.LockResult"
enum="VideoFullscreenOrientationLockResult">
<owner>mlamouri@chromium.org</owner>
<summary>
Result of the orientation lock attempt when a video enters fullscreen.
</summary>
</histogram>
<histogram name="Media.Video.FullscreenOrientationLock.MetadataAvailability"
enum="VideoFullscreenOrientationLockMetadataAvailability">
<owner>mlamouri@chromium.org</owner>
<summary>
Status of the metadata when attempting to lock the screen orientation for a
fullscreen video.
</summary>
</histogram>
<histogram name="Media.Video.KeyFrameDistance" units="ms"> <histogram name="Media.Video.KeyFrameDistance" units="ms">
<owner>avayvod@chromium.org</owner> <owner>avayvod@chromium.org</owner>
<owner>dalecurtis@chromium.org</owner> <owner>dalecurtis@chromium.org</owner>
...@@ -106225,6 +106242,18 @@ value. ...@@ -106225,6 +106242,18 @@ value.
<int value="9" label="UYVY"/> <int value="9" label="UYVY"/>
</enum> </enum>
<enum name="VideoFullscreenOrientationLockMetadataAvailability" type="int">
<int value="0" label="Available"/>
<int value="1" label="Missing"/>
<int value="2" label="Received (after Missing)"/>
</enum>
<enum name="VideoFullscreenOrientationLockResult" type="int">
<int value="0" label="Already locked, no attempt"/>
<int value="1" label="Portrait"/>
<int value="2" label="Landscape"/>
</enum>
<enum name="VideoPixelFormat" type="int"> <enum name="VideoPixelFormat" type="int">
<obsolete> <obsolete>
Deprecated as of 05/2015. Substituted by VideoFormat. Deprecated as of 05/2015. Substituted by VideoFormat.
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