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

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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void cancelDeferredLoad(); 378 void cancelDeferredLoad();
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
387 // autoplay metrics. If we were already in a stopped state, then
388 // this does nothing.
389 void recordMetricsIfPausing();
390 // Could stopping at this point be considered a bailout of playback?
391 // (as in, "The user really didn't want to play this").
392 bool isBailout() const;
393 void autoplayMediaEncountered();
394 void allowVideoRendering(); 388 void allowVideoRendering();
395 389
396 void updateVolume(); 390 void updateVolume();
397 void updatePlayState(); 391 void updatePlayState();
398 bool potentiallyPlaying() const; 392 bool potentiallyPlaying() const;
399 bool stoppedDueToErrors() const; 393 bool stoppedDueToErrors() const;
400 bool couldPlayIfEnoughData() const; 394 bool couldPlayIfEnoughData() const;
401 395
402 // Generally the presence of the loop attribute should be considered to mean playback 396 // 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 397 // has not "ended", as "ended" and "looping" are mutually exclusive. See
(...skipping 11 matching lines...) Expand all
415 TextTrackContainer& ensureTextTrackContainer(); 409 TextTrackContainer& ensureTextTrackContainer();
416 410
417 void* preDispatchEventHandler(Event*) final; 411 void* preDispatchEventHandler(Event*) final;
418 412
419 void changeNetworkStateFromLoadingToIdle(); 413 void changeNetworkStateFromLoadingToIdle();
420 414
421 bool isAutoplaying() const { return m_autoplaying; } 415 bool isAutoplaying() const { return m_autoplaying; }
422 416
423 void setAllowHiddenVolumeControls(bool); 417 void setAllowHiddenVolumeControls(bool);
424 418
425 void recordAutoplayMetric(AutoplayMetrics);
426
427 WebMediaPlayer::CORSMode corsMode() const; 419 WebMediaPlayer::CORSMode corsMode() const;
428 420
429 // Returns the "direction of playback" value as specified in the HTML5 spec. 421 // Returns the "direction of playback" value as specified in the HTML5 spec.
430 enum DirectionOfPlayback { Backward, Forward }; 422 enum DirectionOfPlayback { Backward, Forward };
431 DirectionOfPlayback directionOfPlayback() const; 423 DirectionOfPlayback directionOfPlayback() const;
432 424
433 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects 425 // 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 426 // advertise they have audio and/or video, but don't explicitly signal them via
435 // addAudioTrack() and addVideoTrack(). 427 // addAudioTrack() and addVideoTrack().
436 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. 428 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info.
437 void createPlaceholderTracksIfNecessary(); 429 void createPlaceholderTracksIfNecessary();
438 430
439 // Sets the selected/enabled tracks if they aren't set before we initially 431 // Sets the selected/enabled tracks if they aren't set before we initially
440 // transition to HAVE_METADATA. 432 // transition to HAVE_METADATA.
441 void selectInitialTracksIfNecessary(); 433 void selectInitialTracksIfNecessary();
442 434
443 // Return true if and only if we require a user gesture before letting 435 // Return true if and only if we require a user gesture before letting
444 // the media play. 436 // the media play.
445 bool isUserGestureRequiredForPlay() const; 437 bool isUserGestureRequiredForPlay() const;
446 void removeUserGestureRequirement(); 438 // If the user gesture is required, then this will remove it. If the
447 void setInitialPlayWithoutUserGestures(bool); 439 // media is later autoplayed, then the supplied reason will be recorded.
440 void removeUserGestureRequirement(AutoplayMetrics);
448 441
449 void setNetworkState(NetworkState); 442 void setNetworkState(NetworkState);
450 443
451 void audioTracksTimerFired(Timer<HTMLMediaElement>*); 444 void audioTracksTimerFired(Timer<HTMLMediaElement>*);
452 445
453 // TODO(liberato): remove once autoplay gesture override experiment conclude s. 446 // TODO(liberato): remove once autoplay gesture override experiment conclude s.
454 void triggerAutoplayViewportCheckForTesting(); 447 void triggerAutoplayViewportCheckForTesting();
455 448
456 Timer<HTMLMediaElement> m_loadTimer; 449 Timer<HTMLMediaElement> m_loadTimer;
457 Timer<HTMLMediaElement> m_progressEventTimer; 450 Timer<HTMLMediaElement> m_progressEventTimer;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 bool m_completelyLoaded : 1; 538 bool m_completelyLoaded : 1;
546 bool m_havePreparedToPlay : 1; 539 bool m_havePreparedToPlay : 1;
547 bool m_delayingLoadForPreloadNone : 1; 540 bool m_delayingLoadForPreloadNone : 1;
548 541
549 bool m_tracksAreReady : 1; 542 bool m_tracksAreReady : 1;
550 bool m_haveVisibleTextTrack : 1; 543 bool m_haveVisibleTextTrack : 1;
551 bool m_processingPreferenceChange : 1; 544 bool m_processingPreferenceChange : 1;
552 bool m_remoteRoutesAvailable : 1; 545 bool m_remoteRoutesAvailable : 1;
553 bool m_playingRemotely : 1; 546 bool m_playingRemotely : 1;
554 bool m_isFinalizing : 1; 547 bool m_isFinalizing : 1;
555 bool m_initialPlayWithoutUserGesture : 1;
556 bool m_autoplayMediaCounted : 1;
557 // Whether this element is in overlay fullscreen mode. 548 // Whether this element is in overlay fullscreen mode.
558 bool m_inOverlayFullscreenVideo : 1; 549 bool m_inOverlayFullscreenVideo : 1;
559 550
560 PersistentWillBeMember<AudioTrackList> m_audioTracks; 551 PersistentWillBeMember<AudioTrackList> m_audioTracks;
561 PersistentWillBeMember<VideoTrackList> m_videoTracks; 552 PersistentWillBeMember<VideoTrackList> m_videoTracks;
562 PersistentWillBeMember<TextTrackList> m_textTracks; 553 PersistentWillBeMember<TextTrackList> m_textTracks;
563 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; 554 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan;
564 555
565 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; 556 OwnPtrWillBeMember<CueTimeline> m_cueTimeline;
566 557
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 inline bool isHTMLMediaElement(const HTMLElement& element) 623 inline bool isHTMLMediaElement(const HTMLElement& element)
633 { 624 {
634 return isHTMLAudioElement(element) || isHTMLVideoElement(element); 625 return isHTMLAudioElement(element) || isHTMLVideoElement(element);
635 } 626 }
636 627
637 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 628 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
638 629
639 } // namespace blink 630 } // namespace blink
640 631
641 #endif // HTMLMediaElement_h 632 #endif // HTMLMediaElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698