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

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: simplified paused logic Created 4 years, 9 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 bool isURLAttribute(const Attribute&) const override; 272 bool isURLAttribute(const Attribute&) const override;
273 void attach(const AttachContext& = AttachContext()) override; 273 void attach(const AttachContext& = AttachContext()) override;
274 274
275 void didMoveToNewDocument(Document& oldDocument) override; 275 void didMoveToNewDocument(Document& oldDocument) override;
276 virtual KURL posterImageURL() const { return KURL(); } 276 virtual KURL posterImageURL() const { return KURL(); }
277 277
278 enum DisplayMode { Unknown, Poster, Video }; 278 enum DisplayMode { Unknown, Poster, Video };
279 DisplayMode getDisplayMode() const { return m_displayMode; } 279 DisplayMode getDisplayMode() const { return m_displayMode; }
280 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } 280 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; }
281 281
282 void recordAutoplayMetric(AutoplayMetrics);
283
282 private: 284 private:
283 void resetMediaPlayerAndMediaSource(); 285 void resetMediaPlayerAndMediaSource();
284 286
285 bool alwaysCreateUserAgentShadowRoot() const final { return true; } 287 bool alwaysCreateUserAgentShadowRoot() const final { return true; }
286 bool areAuthorShadowsAllowed() const final { return false; } 288 bool areAuthorShadowsAllowed() const final { return false; }
287 289
288 bool supportsFocus() const final; 290 bool supportsFocus() const final;
289 bool isMouseFocusable() const final; 291 bool isMouseFocusable() const final;
290 bool layoutObjectIsNeeded(const ComputedStyle&) override; 292 bool layoutObjectIsNeeded(const ComputedStyle&) override;
291 LayoutObject* createLayoutObject(const ComputedStyle&) override; 293 LayoutObject* createLayoutObject(const ComputedStyle&) override;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); 380 void deferredLoadTimerFired(Timer<HTMLMediaElement>*);
379 381
380 void markCaptionAndSubtitleTracksAsUnconfigured(); 382 void markCaptionAndSubtitleTracksAsUnconfigured();
381 383
382 // This does not check user gesture restrictions. 384 // This does not check user gesture restrictions.
383 void playInternal(); 385 void playInternal();
384 386
385 // This does not change the buffering strategy. 387 // This does not change the buffering strategy.
386 void pauseInternal(); 388 void pauseInternal();
387 389
388 // If we are about to enter a paused state, call this to record
389 // autoplay metrics. If we were already in a stopped state, then
390 // this does nothing.
391 void recordMetricsIfPausing();
392 // Could stopping at this point be considered a bailout of playback?
393 // (as in, "The user really didn't want to play this").
394 bool isBailout() const;
395 void autoplayMediaEncountered();
396 void allowVideoRendering(); 390 void allowVideoRendering();
397 391
398 void updateVolume(); 392 void updateVolume();
399 void updatePlayState(); 393 void updatePlayState();
400 bool potentiallyPlaying() const; 394 bool potentiallyPlaying() const;
401 bool stoppedDueToErrors() const; 395 bool stoppedDueToErrors() const;
402 bool couldPlayIfEnoughData() const; 396 bool couldPlayIfEnoughData() const;
403 397
404 // Generally the presence of the loop attribute should be considered to mean playback 398 // Generally the presence of the loop attribute should be considered to mean playback
405 // has not "ended", as "ended" and "looping" are mutually exclusive. See 399 // has not "ended", as "ended" and "looping" are mutually exclusive. See
(...skipping 11 matching lines...) Expand all
417 TextTrackContainer& ensureTextTrackContainer(); 411 TextTrackContainer& ensureTextTrackContainer();
418 412
419 void* preDispatchEventHandler(Event*) final; 413 void* preDispatchEventHandler(Event*) final;
420 414
421 void changeNetworkStateFromLoadingToIdle(); 415 void changeNetworkStateFromLoadingToIdle();
422 416
423 bool isAutoplaying() const { return m_autoplaying; } 417 bool isAutoplaying() const { return m_autoplaying; }
424 418
425 void setAllowHiddenVolumeControls(bool); 419 void setAllowHiddenVolumeControls(bool);
426 420
427 void recordAutoplayMetric(AutoplayMetrics);
428
429 WebMediaPlayer::CORSMode corsMode() const; 421 WebMediaPlayer::CORSMode corsMode() const;
430 422
431 // Returns the "direction of playback" value as specified in the HTML5 spec. 423 // Returns the "direction of playback" value as specified in the HTML5 spec.
432 enum DirectionOfPlayback { Backward, Forward }; 424 enum DirectionOfPlayback { Backward, Forward };
433 DirectionOfPlayback getDirectionOfPlayback() const; 425 DirectionOfPlayback getDirectionOfPlayback() const;
434 426
435 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects 427 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects
436 // advertise they have audio and/or video, but don't explicitly signal them via 428 // advertise they have audio and/or video, but don't explicitly signal them via
437 // addAudioTrack() and addVideoTrack(). 429 // addAudioTrack() and addVideoTrack().
438 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. 430 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info.
439 void createPlaceholderTracksIfNecessary(); 431 void createPlaceholderTracksIfNecessary();
440 432
441 // Sets the selected/enabled tracks if they aren't set before we initially 433 // Sets the selected/enabled tracks if they aren't set before we initially
442 // transition to HAVE_METADATA. 434 // transition to HAVE_METADATA.
443 void selectInitialTracksIfNecessary(); 435 void selectInitialTracksIfNecessary();
444 436
445 // Return true if and only if we require a user gesture before letting 437 // Return true if and only if we require a user gesture before letting
446 // the media play. 438 // the media play.
447 bool isUserGestureRequiredForPlay() const; 439 bool isUserGestureRequiredForPlay() const;
440
441 // If the user gesture is required, then this will remove it. Note that
442 // one should not generally call this method directly; use the one on
443 // m_helper and give it a reason.
448 void removeUserGestureRequirement(); 444 void removeUserGestureRequirement();
449 void setInitialPlayWithoutUserGestures(bool);
450 445
451 void setNetworkState(NetworkState); 446 void setNetworkState(NetworkState);
452 447
453 void audioTracksTimerFired(Timer<HTMLMediaElement>*); 448 void audioTracksTimerFired(Timer<HTMLMediaElement>*);
454 449
455 // TODO(liberato): remove once autoplay gesture override experiment conclude s. 450 // TODO(liberato): remove once autoplay gesture override experiment conclude s.
456 void triggerAutoplayViewportCheckForTesting(); 451 void triggerAutoplayViewportCheckForTesting();
457 452
458 void scheduleResolvePlayPromises(); 453 void scheduleResolvePlayPromises();
459 void scheduleRejectPlayPromises(ExceptionCode); 454 void scheduleRejectPlayPromises(ExceptionCode);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 bool m_sentEndEvent : 1; 548 bool m_sentEndEvent : 1;
554 549
555 bool m_closedCaptionsVisible : 1; 550 bool m_closedCaptionsVisible : 1;
556 551
557 bool m_ignorePreloadNone : 1; 552 bool m_ignorePreloadNone : 1;
558 bool m_tracksAreReady : 1; 553 bool m_tracksAreReady : 1;
559 bool m_processingPreferenceChange : 1; 554 bool m_processingPreferenceChange : 1;
560 bool m_remoteRoutesAvailable : 1; 555 bool m_remoteRoutesAvailable : 1;
561 bool m_playingRemotely : 1; 556 bool m_playingRemotely : 1;
562 bool m_isFinalizing : 1; 557 bool m_isFinalizing : 1;
563 bool m_initialPlayWithoutUserGesture : 1;
564 bool m_autoplayMediaCounted : 1;
565 // Whether this element is in overlay fullscreen mode. 558 // Whether this element is in overlay fullscreen mode.
566 bool m_inOverlayFullscreenVideo : 1; 559 bool m_inOverlayFullscreenVideo : 1;
567 560
568 PersistentWillBeMember<AudioTrackList> m_audioTracks; 561 PersistentWillBeMember<AudioTrackList> m_audioTracks;
569 PersistentWillBeMember<VideoTrackList> m_videoTracks; 562 PersistentWillBeMember<VideoTrackList> m_videoTracks;
570 PersistentWillBeMember<TextTrackList> m_textTracks; 563 PersistentWillBeMember<TextTrackList> m_textTracks;
571 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; 564 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan;
572 565
573 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; 566 OwnPtrWillBeMember<CueTimeline> m_cueTimeline;
574 567
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 DECLARE_TRACE(); 617 DECLARE_TRACE();
625 618
626 private: 619 private:
627 WebAudioSourceProvider* m_webAudioSourceProvider; 620 WebAudioSourceProvider* m_webAudioSourceProvider;
628 PersistentWillBeMember<AudioClientImpl> m_client; 621 PersistentWillBeMember<AudioClientImpl> m_client;
629 Mutex provideInputLock; 622 Mutex provideInputLock;
630 }; 623 };
631 624
632 AudioSourceProviderImpl m_audioSourceProvider; 625 AudioSourceProviderImpl m_audioSourceProvider;
633 626
627 class AutoplayHelperClientImpl;
628
634 friend class Internals; 629 friend class Internals;
635 friend class TrackDisplayUpdateScope; 630 friend class TrackDisplayUpdateScope;
636 friend class AutoplayExperimentHelper; 631 friend class AutoplayExperimentHelper;
637 friend class MediaControlsTest; 632 friend class MediaControlsTest;
638 633
639 AutoplayExperimentHelper m_autoplayHelper; 634 OwnPtrWillBeMember<AutoplayExperimentHelper::Client> m_autoplayHelperClient;
635 OwnPtrWillBeMember<AutoplayExperimentHelper> m_autoplayHelper;
640 636
641 static URLRegistry* s_mediaStreamRegistry; 637 static URLRegistry* s_mediaStreamRegistry;
642 }; 638 };
643 639
644 inline bool isHTMLMediaElement(const HTMLElement& element) 640 inline bool isHTMLMediaElement(const HTMLElement& element)
645 { 641 {
646 return isHTMLAudioElement(element) || isHTMLVideoElement(element); 642 return isHTMLAudioElement(element) || isHTMLVideoElement(element);
647 } 643 }
648 644
649 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 645 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
650 646
651 } // namespace blink 647 } // namespace blink
652 648
653 #endif // HTMLMediaElement_h 649 #endif // HTMLMediaElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698