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

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

Issue 1470153004: Autoplay experiment metric fixes and additions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl feedback. Created 5 years 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 bool paused() const; 133 bool paused() const;
134 double defaultPlaybackRate() const; 134 double defaultPlaybackRate() const;
135 void setDefaultPlaybackRate(double); 135 void setDefaultPlaybackRate(double);
136 double playbackRate() const; 136 double playbackRate() const;
137 void setPlaybackRate(double); 137 void setPlaybackRate(double);
138 void updatePlaybackRate(); 138 void updatePlaybackRate();
139 TimeRanges* played(); 139 TimeRanges* played();
140 TimeRanges* seekable() const; 140 TimeRanges* seekable() const;
141 bool ended() const; 141 bool ended() const;
142 bool autoplay() const; 142 bool autoplay() const;
143 enum class RecordMetricsBehavior { DoNotRecord, DoRecord }; 143 enum class RecordMetricsBehavior { DoNotRecord, RecordOnSandboxFailure };
144 bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoN otRecord); 144 bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoN otRecord);
145 bool loop() const; 145 bool loop() const;
146 void setLoop(bool); 146 void setLoop(bool);
147 void play(); 147 void play();
148 void pause(); 148 void pause();
149 void requestRemotePlayback(); 149 void requestRemotePlayback();
150 void requestRemotePlaybackControl(); 150 void requestRemotePlaybackControl();
151 151
152 // statistics 152 // statistics
153 unsigned webkitAudioDecodedByteCount() const; 153 unsigned webkitAudioDecodedByteCount() const;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool isURLAttribute(const Attribute&) const override; 273 bool isURLAttribute(const Attribute&) const override;
274 void attach(const AttachContext& = AttachContext()) override; 274 void attach(const AttachContext& = AttachContext()) override;
275 275
276 void didMoveToNewDocument(Document& oldDocument) override; 276 void didMoveToNewDocument(Document& oldDocument) override;
277 virtual KURL posterImageURL() const { return KURL(); } 277 virtual KURL posterImageURL() const { return KURL(); }
278 278
279 enum DisplayMode { Unknown, Poster, Video }; 279 enum DisplayMode { Unknown, Poster, Video };
280 DisplayMode displayMode() const { return m_displayMode; } 280 DisplayMode displayMode() const { return m_displayMode; }
281 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } 281 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; }
282 282
283 void recordAutoplayMetric(AutoplayMetrics);
284
283 private: 285 private:
284 void resetMediaPlayerAndMediaSource(); 286 void resetMediaPlayerAndMediaSource();
285 287
286 bool alwaysCreateUserAgentShadowRoot() const final { return true; } 288 bool alwaysCreateUserAgentShadowRoot() const final { return true; }
287 bool areAuthorShadowsAllowed() const final { return false; } 289 bool areAuthorShadowsAllowed() const final { return false; }
288 290
289 bool supportsFocus() const final; 291 bool supportsFocus() const final;
290 bool isMouseFocusable() const final; 292 bool isMouseFocusable() const final;
291 bool layoutObjectIsNeeded(const ComputedStyle&) override; 293 bool layoutObjectIsNeeded(const ComputedStyle&) override;
292 LayoutObject* createLayoutObject(const ComputedStyle&) override; 294 LayoutObject* createLayoutObject(const ComputedStyle&) override;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 void startDeferredLoad(); 379 void startDeferredLoad();
378 void executeDeferredLoad(); 380 void executeDeferredLoad();
379 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); 381 void deferredLoadTimerFired(Timer<HTMLMediaElement>*);
380 382
381 void markCaptionAndSubtitleTracksAsUnconfigured(); 383 void markCaptionAndSubtitleTracksAsUnconfigured();
382 384
383 // This does not check user gesture restrictions. 385 // This does not check user gesture restrictions.
384 void playInternal(); 386 void playInternal();
385 387
386 // If we are about to enter a paused state, call this to record 388 // If we are about to enter a paused state, call this to record
387 // autoplay metrics. If we were already in a stopped state, then 389 // autoplay metrics.
388 // this does nothing. 390 void recordMetricsBeforePause();
389 void recordMetricsIfPausing(); 391 void recordMetricsAtPlaybackEnd();
390 // Could stopping at this point be considered a bailout of playback? 392 // Could stopping at this point be considered a bailout of playback?
391 // (as in, "The user really didn't want to play this"). 393 // (as in, "The user really didn't want to play this").
392 bool isBailout() const; 394 bool isBailout() const;
393 void autoplayMediaEncountered();
394 void allowVideoRendering(); 395 void allowVideoRendering();
395 396
396 void updateVolume(); 397 void updateVolume();
397 void updatePlayState(); 398 void updatePlayState();
398 bool potentiallyPlaying() const; 399 bool potentiallyPlaying() const;
399 bool stoppedDueToErrors() const; 400 bool stoppedDueToErrors() const;
400 bool couldPlayIfEnoughData() const; 401 bool couldPlayIfEnoughData() const;
401 402
402 // Generally the presence of the loop attribute should be considered to mean playback 403 // Generally the presence of the loop attribute should be considered to mean playback
403 // has not "ended", as "ended" and "looping" are mutually exclusive. See 404 // has not "ended", as "ended" and "looping" are mutually exclusive. See
(...skipping 11 matching lines...) Expand all
415 TextTrackContainer& ensureTextTrackContainer(); 416 TextTrackContainer& ensureTextTrackContainer();
416 417
417 void* preDispatchEventHandler(Event*) final; 418 void* preDispatchEventHandler(Event*) final;
418 419
419 void changeNetworkStateFromLoadingToIdle(); 420 void changeNetworkStateFromLoadingToIdle();
420 421
421 bool isAutoplaying() const { return m_autoplaying; } 422 bool isAutoplaying() const { return m_autoplaying; }
422 423
423 void setAllowHiddenVolumeControls(bool); 424 void setAllowHiddenVolumeControls(bool);
424 425
425 void recordAutoplayMetric(AutoplayMetrics);
426
427 WebMediaPlayer::CORSMode corsMode() const; 426 WebMediaPlayer::CORSMode corsMode() const;
428 427
429 // Returns the "direction of playback" value as specified in the HTML5 spec. 428 // Returns the "direction of playback" value as specified in the HTML5 spec.
430 enum DirectionOfPlayback { Backward, Forward }; 429 enum DirectionOfPlayback { Backward, Forward };
431 DirectionOfPlayback directionOfPlayback() const; 430 DirectionOfPlayback directionOfPlayback() const;
432 431
433 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects 432 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects
434 // advertise they have audio and/or video, but don't explicitly signal them via 433 // advertise they have audio and/or video, but don't explicitly signal them via
435 // addAudioTrack() and addVideoTrack(). 434 // addAudioTrack() and addVideoTrack().
436 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. 435 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info.
437 void createPlaceholderTracksIfNecessary(); 436 void createPlaceholderTracksIfNecessary();
438 437
439 // Sets the selected/enabled tracks if they aren't set before we initially 438 // Sets the selected/enabled tracks if they aren't set before we initially
440 // transition to HAVE_METADATA. 439 // transition to HAVE_METADATA.
441 void selectInitialTracksIfNecessary(); 440 void selectInitialTracksIfNecessary();
442 441
443 // Return true if and only if we require a user gesture before letting 442 // Return true if and only if we require a user gesture before letting
444 // the media play. 443 // the media play.
445 bool isUserGestureRequiredForPlay() const; 444 bool isUserGestureRequiredForPlay() const;
446 void removeUserGestureRequirement(); 445 // If the user gesture is required, then this will remove it. If the
447 void setInitialPlayWithoutUserGestures(bool); 446 // media is later autoplayed, then the supplied reason will be recorded.
447 void removeUserGestureRequirement(AutoplayMetrics);
448 void autoplayMediaEncountered();
448 449
449 void setNetworkState(NetworkState); 450 void setNetworkState(NetworkState);
450 451
451 void audioTracksTimerFired(Timer<HTMLMediaElement>*); 452 void audioTracksTimerFired(Timer<HTMLMediaElement>*);
452 453
453 // TODO(liberato): remove once autoplay gesture override experiment conclude s. 454 // TODO(liberato): remove once autoplay gesture override experiment conclude s.
454 void triggerAutoplayViewportCheckForTesting(); 455 void triggerAutoplayViewportCheckForTesting();
455 456
456 Timer<HTMLMediaElement> m_loadTimer; 457 Timer<HTMLMediaElement> m_loadTimer;
457 Timer<HTMLMediaElement> m_progressEventTimer; 458 Timer<HTMLMediaElement> m_progressEventTimer;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 }; 619 };
619 620
620 AudioSourceProviderImpl m_audioSourceProvider; 621 AudioSourceProviderImpl m_audioSourceProvider;
621 #endif 622 #endif
622 623
623 friend class Internals; 624 friend class Internals;
624 friend class TrackDisplayUpdateScope; 625 friend class TrackDisplayUpdateScope;
625 friend class AutoplayExperimentHelper; 626 friend class AutoplayExperimentHelper;
626 627
627 AutoplayExperimentHelper m_autoplayHelper; 628 AutoplayExperimentHelper m_autoplayHelper;
629 // Reason that autoplay would be allowed to proceed without a user gesture.
philipj_slow 2015/11/26 15:30:56 Can these be stored in AutoplayExperimentHelper?
liberato (no reviews please) 2015/12/02 00:58:09 Done.
630 AutoplayMetrics m_autoplayDeferredMetric;
631 // Did we record that this media element exists in the metrics yet?
632 bool m_recordedElement;
628 633
629 static URLRegistry* s_mediaStreamRegistry; 634 static URLRegistry* s_mediaStreamRegistry;
630 }; 635 };
631 636
632 inline bool isHTMLMediaElement(const HTMLElement& element) 637 inline bool isHTMLMediaElement(const HTMLElement& element)
633 { 638 {
634 return isHTMLAudioElement(element) || isHTMLVideoElement(element); 639 return isHTMLAudioElement(element) || isHTMLVideoElement(element);
635 } 640 }
636 641
637 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 642 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
638 643
639 } // namespace blink 644 } // namespace blink
640 645
641 #endif // HTMLMediaElement_h 646 #endif // HTMLMediaElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698