Bug 1685399 - part10 : add chrome-only attributes to allow us check accumulated time during testing. r=padenot,emilio

Differential Revision: https://phabricator.services.mozilla.com/D101264
This commit is contained in:
alwu 2021-01-15 19:58:13 +00:00
Родитель 92e9f1a852
Коммит 2063aa51ae
7 изменённых файлов: 67 добавлений и 0 удалений

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

@ -2151,6 +2151,18 @@ bool HTMLMediaElement::IsVideoDecodingSuspended() const {
return mDecoder && mDecoder->IsVideoDecodingSuspended();
}
double HTMLMediaElement::TotalPlayTime() const {
return mDecoder ? mDecoder->GetTotalPlayTimeInSeconds() : -1.0;
}
double HTMLMediaElement::InvisiblePlayTime() const {
return mDecoder ? mDecoder->GetInvisibleVideoPlayTimeInSeconds() : -1.0;
}
double HTMLMediaElement::VideoDecodeSuspendedTime() const {
return mDecoder ? mDecoder->GetVideoDecodeSuspendedTimeInSeconds() : -1.0;
}
already_AddRefed<layers::Image> HTMLMediaElement::GetCurrentImage() {
MarkAsTainted();

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

@ -622,6 +622,12 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// For use by mochitests.
bool IsVideoDecodingSuspended() const;
// These functions return accumulated time, which are used for the telemetry
// usage. Return -1 for error.
double TotalPlayTime() const;
double InvisiblePlayTime() const;
double VideoDecodeSuspendedTime() const;
// Synchronously, return the next video frame and mark the element unable to
// participate in decode suspending.
//

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

@ -1387,6 +1387,18 @@ void MediaDecoder::NotifyAudibleStateChanged() {
GetOwner()->SetAudibleState(mIsAudioDataAudible);
}
double MediaDecoder::GetTotalPlayTimeInSeconds() const {
return mTelemetryProbesReporter->GetTotalPlayTimeInSeconds();
}
double MediaDecoder::GetInvisibleVideoPlayTimeInSeconds() const {
return mTelemetryProbesReporter->GetInvisibleVideoPlayTimeInSeconds();
}
double MediaDecoder::GetVideoDecodeSuspendedTimeInSeconds() const {
return mTelemetryProbesReporter->GetVideoDecodeSuspendedTimeInSeconds();
}
MediaMemoryTracker::MediaMemoryTracker() = default;
void MediaMemoryTracker::InitMemoryReporter() {

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

@ -717,6 +717,11 @@ class MediaDecoder : public DecoderDoctorLifeLogger<MediaDecoder> {
TelemetryProbesReporter::Visibility OwnerVisibility() const;
// They are used for reporting telemetry related results.
double GetTotalPlayTimeInSeconds() const;
double GetInvisibleVideoPlayTimeInSeconds() const;
double GetVideoDecodeSuspendedTimeInSeconds() const;
private:
// Notify owner when the audible state changed
void NotifyAudibleStateChanged();

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

@ -280,5 +280,17 @@ void TelemetryProbesReporter::ReportResultForVideoFrameStatistics(
}
}
double TelemetryProbesReporter::GetTotalPlayTimeInSeconds() const {
return mTotalPlayTime.PeekTotal();
}
double TelemetryProbesReporter::GetInvisibleVideoPlayTimeInSeconds() const {
return mInvisibleVideoPlayTime.PeekTotal();
}
double TelemetryProbesReporter::GetVideoDecodeSuspendedTimeInSeconds() const {
return mVideoDecodeSuspendedTime.PeekTotal();
}
#undef LOG
} // namespace mozilla

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

@ -42,6 +42,10 @@ class TelemetryProbesReporter final {
void OnDecodeResumed();
void OnShutdown();
double GetTotalPlayTimeInSeconds() const;
double GetInvisibleVideoPlayTimeInSeconds() const;
double GetVideoDecodeSuspendedTimeInSeconds() const;
private:
void StartInvisibleVideoTimeAcculator();
void PauseInvisibleVideoTimeAcculator();
@ -80,6 +84,13 @@ class TelemetryProbesReporter final {
return total;
}
double PeekTotal() const {
if (!IsStarted()) {
return mSum.ToSeconds();
}
return (TimeStamp::Now() - mStartTime).ToSeconds();
}
private:
TimeStamp mStartTime;
TimeDuration mSum;

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

@ -230,6 +230,15 @@ partial interface HTMLMediaElement {
[ChromeOnly]
readonly attribute boolean isVideoDecodingSuspended;
[ChromeOnly]
readonly attribute double totalPlayTime;
[ChromeOnly]
readonly attribute double invisiblePlayTime;
[ChromeOnly]
readonly attribute double videoDecodeSuspendedTime;
};
/* Audio Output Devices API */