Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.h

Issue 2101613002: Record the offscreen playing duration of autoplaying muted videos (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 void scheduleRejectPlayPromises(ExceptionCode); 486 void scheduleRejectPlayPromises(ExceptionCode);
487 void scheduleNotifyPlaying(); 487 void scheduleNotifyPlaying();
488 void resolveScheduledPlayPromises(); 488 void resolveScheduledPlayPromises();
489 void rejectScheduledPlayPromises(); 489 void rejectScheduledPlayPromises();
490 void rejectPlayPromises(ExceptionCode, const String&); 490 void rejectPlayPromises(ExceptionCode, const String&);
491 void rejectPlayPromisesInternal(ExceptionCode, const String&); 491 void rejectPlayPromisesInternal(ExceptionCode, const String&);
492 492
493 EnumerationHistogram& showControlsHistogram() const; 493 EnumerationHistogram& showControlsHistogram() const;
494 494
495 void recordAutoplaySourceMetric(int source); 495 void recordAutoplaySourceMetric(int source);
496 void recordAutoplayVideoOffscreenMetric(double timeDeltaMS);
496 497
497 void onVisibilityChangedForAutoplay(bool isVisible); 498 void onVisibilityChangedForAutoplay(bool isVisible);
498 499
499 UnthrottledTimer<HTMLMediaElement> m_loadTimer; 500 UnthrottledTimer<HTMLMediaElement> m_loadTimer;
500 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; 501 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer;
501 UnthrottledTimer<HTMLMediaElement> m_playbackProgressTimer; 502 UnthrottledTimer<HTMLMediaElement> m_playbackProgressTimer;
502 UnthrottledTimer<HTMLMediaElement> m_audioTracksTimer; 503 UnthrottledTimer<HTMLMediaElement> m_audioTracksTimer;
503 Member<TimeRanges> m_playedTimeRanges; 504 Member<TimeRanges> m_playedTimeRanges;
504 Member<GenericEventQueue> m_asyncEventQueue; 505 Member<GenericEventQueue> m_asyncEventQueue;
505 506
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 std::unique_ptr<CancellableTaskFactory> m_playPromiseRejectTask; 606 std::unique_ptr<CancellableTaskFactory> m_playPromiseRejectTask;
606 HeapVector<Member<ScriptPromiseResolver>> m_playPromiseResolveList; 607 HeapVector<Member<ScriptPromiseResolver>> m_playPromiseResolveList;
607 HeapVector<Member<ScriptPromiseResolver>> m_playPromiseRejectList; 608 HeapVector<Member<ScriptPromiseResolver>> m_playPromiseRejectList;
608 ExceptionCode m_playPromiseErrorCode; 609 ExceptionCode m_playPromiseErrorCode;
609 610
610 // This is a weak reference, since m_audioSourceNode holds a reference to us . 611 // This is a weak reference, since m_audioSourceNode holds a reference to us .
611 // TODO(Oilpan): Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem. 612 // TODO(Oilpan): Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem.
612 GC_PLUGIN_IGNORE("http://crbug.com/404577") 613 GC_PLUGIN_IGNORE("http://crbug.com/404577")
613 WeakMember<AudioSourceProviderClient> m_audioSourceNode; 614 WeakMember<AudioSourceProviderClient> m_audioSourceNode;
614 615
616 // Variables used for recording the duration of autoplay muted video playing offscreen.
617 // The variables are valid when |m_autoplayOffscrenVisibilityObserver| is no n-null. Whenever the playback pauses, the UMA is recorded, and |m_autoplayOffscr eenVisibilityObserver| is set to null.
618 double m_mutedVideoAutoplayStartTimeMS;
619 double m_mutedVideoAutoplayOffscreenDurationMS;
620 bool m_isVisible;
621 bool m_isAutoplayFromAttribute;
622 Member<ElementVisibilityObserver> m_autoplayOffscreenVisibilityObserver;
623
624 void maybeRecordMutedVideoAutoplayOffscreenDuration();
625
626 void onVisibilityChangedForAutoplayOffscreen(bool isVisibile);
627
615 // AudioClientImpl wraps an AudioSourceProviderClient. 628 // AudioClientImpl wraps an AudioSourceProviderClient.
616 // When the audio format is known, Chromium calls setFormat(). 629 // When the audio format is known, Chromium calls setFormat().
617 class AudioClientImpl final : public GarbageCollectedFinalized<AudioClientIm pl>, public WebAudioSourceProviderClient { 630 class AudioClientImpl final : public GarbageCollectedFinalized<AudioClientIm pl>, public WebAudioSourceProviderClient {
618 public: 631 public:
619 explicit AudioClientImpl(AudioSourceProviderClient* client) 632 explicit AudioClientImpl(AudioSourceProviderClient* client)
620 : m_client(client) 633 : m_client(client)
621 { 634 {
622 } 635 }
623 636
624 ~AudioClientImpl() override { } 637 ~AudioClientImpl() override { }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 inline bool isHTMLMediaElement(const HTMLElement& element) 695 inline bool isHTMLMediaElement(const HTMLElement& element)
683 { 696 {
684 return isHTMLAudioElement(element) || isHTMLVideoElement(element); 697 return isHTMLAudioElement(element) || isHTMLVideoElement(element);
685 } 698 }
686 699
687 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 700 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
688 701
689 } // namespace blink 702 } // namespace blink
690 703
691 #endif // HTMLMediaElement_h 704 #endif // HTMLMediaElement_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698