From 5335681cd2ab05ad47e81be7722c9eee19d54065 Mon Sep 17 00:00:00 2001 From: adeshkp Date: Sat, 12 Jan 2019 06:20:31 -0500 Subject: Telemetry: Remove stubs and related code --- dom/html/HTMLFormElement.cpp | 3 - dom/html/HTMLImageElement.cpp | 2 - dom/html/HTMLMediaElement.cpp | 227 ------------------------------------------ dom/html/HTMLMediaElement.h | 81 --------------- dom/html/TextTrackManager.cpp | 16 --- dom/html/TextTrackManager.h | 7 -- 6 files changed, 336 deletions(-) (limited to 'dom/html') diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 0393ed3e0..6bea19a2b 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -51,7 +51,6 @@ #include "nsIWebProgress.h" #include "nsIDocShell.h" #include "nsIPrompt.h" -#include "nsISecurityUITelemetry.h" #include "nsIStringBundle.h" // radio buttons @@ -954,8 +953,6 @@ HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL, return rv; } *aCancelSubmit = (buttonPressed == 1); - uint32_t telemetryBucket = - nsISecurityUITelemetry::WARNING_CONFIRM_POST_TO_INSECURE_FROM_SECURE; return NS_OK; } diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index 4b2e7a07b..fab1cdef4 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -1345,8 +1345,6 @@ HTMLImageElement::FlushUseCounters() nsCOMPtr container; request->GetImage(getter_AddRefs(container)); - - static_cast(container.get())->ReportUseCounters(); } } // namespace dom diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 6171e1766..3b19d42c6 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -1037,14 +1037,6 @@ void HTMLMediaElement::ShutdownDecoder() void HTMLMediaElement::AbortExistingLoads() { -#ifdef MOZ_EME - // If there is no existing decoder then we don't have anything to - // report. This prevents reporting the initial load from an - // empty video element as a failed EME load. - if (mDecoder) { - ReportEMETelemetry(); - } -#endif // Abort any already-running instance of the resource selection algorithm. mLoadWaitStatus = NOT_WAITING; @@ -1900,7 +1892,6 @@ NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime) void HTMLMediaElement::FastSeek(double aTime, ErrorResult& aRv) { - LOG(LogLevel::Debug, ("Reporting telemetry VIDEO_FASTSEEK_USED")); RefPtr tobeDropped = Seek(aTime, SeekTarget::PrevSyncPoint, aRv); } @@ -3648,191 +3639,6 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen return rv; } -/* static */ -void HTMLMediaElement::VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure) -{ - MOZ_ASSERT(NS_IsMainThread()); - auto element = static_cast(aClosure); - element->mVideoDecodeSuspendTime.Start(); - element->mVideoDecodeSuspendTimer = nullptr; -} - -void HTMLMediaElement::HiddenVideoStart() -{ - MOZ_ASSERT(NS_IsMainThread()); - mHiddenPlayTime.Start(); - if (mVideoDecodeSuspendTimer) { - // Already started, just keep it running. - return; - } - mVideoDecodeSuspendTimer = do_CreateInstance("@mozilla.org/timer;1"); - mVideoDecodeSuspendTimer->InitWithNamedFuncCallback( - VideoDecodeSuspendTimerCallback, this, - MediaPrefs::MDSMSuspendBackgroundVideoDelay(), nsITimer::TYPE_ONE_SHOT, - "HTMLMediaElement::VideoDecodeSuspendTimerCallback"); -} - -void HTMLMediaElement::HiddenVideoStop() -{ - MOZ_ASSERT(NS_IsMainThread()); - mHiddenPlayTime.Pause(); - mVideoDecodeSuspendTime.Pause(); - if (!mVideoDecodeSuspendTimer) { - return; - } - mVideoDecodeSuspendTimer->Cancel(); - mVideoDecodeSuspendTimer = nullptr; -} - -#ifdef MOZ_EME -void -HTMLMediaElement::ReportEMETelemetry() -{ - // Report telemetry for EME videos when a page is unloaded. - NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); - if (mIsEncrypted && Preferences::GetBool("media.eme.enabled")) { - LOG(LogLevel::Debug, ("%p VIDEO_EME_PLAY_SUCCESS = %s", - this, mLoadedDataFired ? "true" : "false")); - } -} -#endif - -void -HTMLMediaElement::ReportTelemetry() -{ - // Report telemetry for videos when a page is unloaded. We - // want to know data on what state the video is at when - // the user has exited. - enum UnloadedState { - ENDED = 0, - PAUSED = 1, - STALLED = 2, - SEEKING = 3, - OTHER = 4 - }; - - UnloadedState state = OTHER; - if (Seeking()) { - state = SEEKING; - } - else if (Ended()) { - state = ENDED; - } - else if (Paused()) { - state = PAUSED; - } - else { - // For buffering we check if the current playback position is at the end - // of a buffered range, within a margin of error. We also consider to be - // buffering if the last frame status was buffering and the ready state is - // HAVE_CURRENT_DATA to account for times where we are in a buffering state - // regardless of what actual data we have buffered. - bool stalled = false; - RefPtr ranges = Buffered(); - const double errorMargin = 0.05; - double t = CurrentTime(); - TimeRanges::index_type index = ranges->Find(t, errorMargin); - ErrorResult ignore; - stalled = index != TimeRanges::NoIndex && - (ranges->End(index, ignore) - t) < errorMargin; - stalled |= mDecoder && NextFrameStatus() == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING && - mReadyState == HTMLMediaElement::HAVE_CURRENT_DATA; - if (stalled) { - state = STALLED; - } - } - - LOG(LogLevel::Debug, ("%p VIDEO_UNLOAD_STATE = %d", this, state)); - - FrameStatisticsData data; - - if (HTMLVideoElement* vid = HTMLVideoElement::FromContentOrNull(this)) { - FrameStatistics* stats = vid->GetFrameStatistics(); - if (stats) { - data = stats->GetFrameStatisticsData(); - if (data.mParsedFrames) { - MOZ_ASSERT(data.mDroppedFrames <= data.mParsedFrames); - // Dropped frames <= total frames, so 'percentage' cannot be higher than - // 100 and therefore can fit in a uint32_t (that Telemetry takes). - uint32_t percentage = 100 * data.mDroppedFrames / data.mParsedFrames; - LOG(LogLevel::Debug, - ("Reporting telemetry DROPPED_FRAMES_IN_VIDEO_PLAYBACK")); - } - } - } - - if (mMediaInfo.HasVideo() && - mMediaInfo.mVideo.mImage.height > 0) { - // We have a valid video. - double playTime = mPlayTime.Total(); - double hiddenPlayTime = mHiddenPlayTime.Total(); - double videoDecodeSuspendTime = mVideoDecodeSuspendTime.Total(); - - LOG(LogLevel::Debug, ("%p VIDEO_PLAY_TIME_MS = %f", this, playTime)); - - LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_MS = %f", this, hiddenPlayTime)); - - if (playTime > 0.0) { - // We have actually played something -> Report some valid-video telemetry. - - // Keyed by audio+video or video alone, and by a resolution range. - nsCString key(mMediaInfo.HasAudio() ? "AV," : "V,"); - static const struct { int32_t mH; const char* mRes; } sResolutions[] = { - { 240, "0(double(data.mInterKeyframeSum_us) - / double(data.mInterKeyframeCount) - / 1000.0 - + 0.5, - UINT32_MAX)); - LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_AVERAGE_MS = %u, keys: '%s' and 'All'", - this, average_ms, key.get())); - - uint32_t max_ms = - uint32_t(std::min((data.mInterKeyFrameMax_us + 500) / 1000, - UINT32_MAX)); - LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_MAX_MS = %u, keys: '%s' and 'All'", - this, max_ms, key.get())); - } else { - // Here, we have played *some* of the video, but didn't get more than 1 - // keyframe. Report '0' if we have played for longer than the video- - // decode-suspend delay (showing recovery would be difficult). - uint32_t suspendDelay_ms = MediaPrefs::MDSMSuspendBackgroundVideoDelay(); - if (uint32_t(playTime * 1000.0) > suspendDelay_ms) { - LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_MAX_MS = 0 (only 1 keyframe), keys: '%s' and 'All'", - this, key.get())); - } - } - } - } -} - void HTMLMediaElement::UnbindFromTree(bool aDeep, bool aNullParent) { @@ -5312,19 +5118,6 @@ nsresult HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) nsCOMPtr event = new nsAsyncEventRunner(aName, this); NS_DispatchToMainThread(event); - if ((aName.EqualsLiteral("play") || aName.EqualsLiteral("playing"))) { - mPlayTime.Start(); - if (IsHidden()) { - HiddenVideoStart(); - } - } else if (aName.EqualsLiteral("waiting")) { - mPlayTime.Pause(); - HiddenVideoStop(); - } else if (aName.EqualsLiteral("pause")) { - mPlayTime.Pause(); - HiddenVideoStop(); - } - return NS_OK; } @@ -5450,11 +5243,6 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE UpdateSrcMediaStreamPlaying(); UpdateAudioChannelPlayingState(); if (aPauseElement) { - ReportTelemetry(); -#ifdef MOZ_EME - ReportEMETelemetry(); -#endif - #ifdef MOZ_EME // For EME content, we may force destruction of the CDM client (and CDM // instance if this is the last client for that CDM instance) and @@ -5506,13 +5294,6 @@ bool HTMLMediaElement::IsBeingDestroyed() void HTMLMediaElement::NotifyOwnerDocumentActivityChanged() { bool visible = !IsHidden(); - if (visible) { - // Visible -> Just pause hidden play time (no-op if already paused). - HiddenVideoStop(); - } else if (mPlayTime.IsStarted()) { - // Not visible, play time is running -> Start hidden play time if needed. - HiddenVideoStart(); - } if (mDecoder && !IsBeingDestroyed()) { mDecoder->NotifyOwnerActivityChanged(visible); @@ -6288,18 +6069,10 @@ HTMLMediaElement::OnVisibilityChange(Visibility aNewVisibility) break; } case Visibility::APPROXIMATELY_NONVISIBLE: { - if (mPlayTime.IsStarted()) { - // Not visible, play time is running -> Start hidden play time if needed. - HiddenVideoStart(); - } - mDecoder->NotifyOwnerActivityChanged(false); break; } case Visibility::APPROXIMATELY_VISIBLE: { - // Visible -> Just pause hidden play time (no-op if already paused). - HiddenVideoStop(); - mDecoder->NotifyOwnerActivityChanged(true); break; } diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index af944a318..3e6cb519d 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1195,29 +1195,6 @@ protected: return isPaused; } - /** - * Video has been playing while hidden and, if feature was enabled, would - * trigger suspending decoder. - * Used to track hidden-video-decode-suspend telemetry. - */ - static void VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure); - /** - * Video is now both: playing and hidden. - * Used to track hidden-video telemetry. - */ - void HiddenVideoStart(); - /** - * Video is not playing anymore and/or has become visible. - * Used to track hidden-video telemetry. - */ - void HiddenVideoStop(); - -#ifdef MOZ_EME - void ReportEMETelemetry(); -#endif - - void ReportTelemetry(); - // Check the permissions for audiochannel. bool CheckAudioChannelPermissions(const nsAString& aType); @@ -1688,65 +1665,7 @@ protected: // before attaching to the DOM tree. bool mUnboundFromTree = false; -public: - // Helper class to measure times for MSE telemetry stats - class TimeDurationAccumulator - { - public: - TimeDurationAccumulator() - : mCount(0) - {} - void Start() - { - if (IsStarted()) { - return; - } - mStartTime = TimeStamp::Now(); - } - void Pause() - { - if (!IsStarted()) { - return; - } - mSum += (TimeStamp::Now() - mStartTime); - mCount++; - mStartTime = TimeStamp(); - } - bool IsStarted() const - { - return !mStartTime.IsNull(); - } - double Total() const - { - if (!IsStarted()) { - return mSum.ToSeconds(); - } - // Add current running time until now, but keep it running. - return (mSum + (TimeStamp::Now() - mStartTime)).ToSeconds(); - } - uint32_t Count() const - { - if (!IsStarted()) { - return mCount; - } - // Count current run in this report, without increasing the stored count. - return mCount + 1; - } - private: - TimeStamp mStartTime; - TimeDuration mSum; - uint32_t mCount; - }; private: - // Total time a video has spent playing. - TimeDurationAccumulator mPlayTime; - - // Total time a video has spent playing while hidden. - TimeDurationAccumulator mHiddenPlayTime; - - // Total time a video has (or would have) spent in video-decode-suspend mode. - TimeDurationAccumulator mVideoDecodeSuspendTime; - // Indicates if user has interacted with the element. // Used to block autoplay when disabled. bool mHasUserInteraction; diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp index cc14858b6..7f9d32794 100644 --- a/dom/html/TextTrackManager.cpp +++ b/dom/html/TextTrackManager.cpp @@ -118,7 +118,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement) , mTimeMarchesOnDispatched(false) , mUpdateCueDisplayDispatched(false) , performedTrackSelection(false) - , mCueTelemetryReported(false) , mShutdown(false) { nsISupports* parentObject = @@ -170,7 +169,6 @@ TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel, mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aReadyState, aTextTrackSource, CompareTextTracks(mMediaElement)); AddCues(track); - ReportTelemetryForTrack(track); if (aTextTrackSource == TextTrackSource::Track) { RefPtr task = @@ -190,7 +188,6 @@ TextTrackManager::AddTextTrack(TextTrack* aTextTrack) WEBVTT_LOG("%p AddTextTrack TextTrack %p",this, aTextTrack); mTextTracks->AddTextTrack(aTextTrack, CompareTextTracks(mMediaElement)); AddCues(aTextTrack); - ReportTelemetryForTrack(aTextTrack); if (aTextTrack->GetTextTrackSource() == TextTrackSource::Track) { RefPtr task = @@ -309,7 +306,6 @@ TextTrackManager::NotifyCueAdded(TextTrackCue& aCue) mNewCues->AddCue(aCue); } DispatchTimeMarchesOn(); - ReportTelemetryForCue(); } void @@ -827,17 +823,5 @@ TextTrackManager::NotifyReset() mLastTimeMarchesOnCalled = 0.0; } -void -TextTrackManager::ReportTelemetryForTrack(TextTrack* aTextTrack) const -{ -/* STUB */ -} - -void -TextTrackManager::ReportTelemetryForCue() -{ -/* STUB */ -} - } // namespace dom } // namespace mozilla diff --git a/dom/html/TextTrackManager.h b/dom/html/TextTrackManager.h index 4ad1a57a7..2375aa4bb 100644 --- a/dom/html/TextTrackManager.h +++ b/dom/html/TextTrackManager.h @@ -148,13 +148,6 @@ private: nsTArray& aTextTracks); bool TrackIsDefault(TextTrack* aTextTrack); - void ReportTelemetryForTrack(TextTrack* aTextTrack) const; - void ReportTelemetryForCue(); - - // If there is at least one cue has been added to the cue list once, we would - // report the usage of cue to Telemetry. - bool mCueTelemetryReported; - class ShutdownObserverProxy final : public nsIObserver { NS_DECL_ISUPPORTS -- cgit v1.2.3