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

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: more oilpan. 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 bool isURLAttribute(const Attribute&) const override; 271 bool isURLAttribute(const Attribute&) const override;
272 void attach(const AttachContext& = AttachContext()) override; 272 void attach(const AttachContext& = AttachContext()) override;
273 273
274 void didMoveToNewDocument(Document& oldDocument) override; 274 void didMoveToNewDocument(Document& oldDocument) override;
275 virtual KURL posterImageURL() const { return KURL(); } 275 virtual KURL posterImageURL() const { return KURL(); }
276 276
277 enum DisplayMode { Unknown, Poster, Video }; 277 enum DisplayMode { Unknown, Poster, Video };
278 DisplayMode getDisplayMode() const { return m_displayMode; } 278 DisplayMode getDisplayMode() const { return m_displayMode; }
279 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } 279 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; }
280 280
281 void recordAutoplayMetric(AutoplayMetrics);
282
281 private: 283 private:
282 void resetMediaPlayerAndMediaSource(); 284 void resetMediaPlayerAndMediaSource();
283 285
284 bool alwaysCreateUserAgentShadowRoot() const final { return true; } 286 bool alwaysCreateUserAgentShadowRoot() const final { return true; }
285 bool areAuthorShadowsAllowed() const final { return false; } 287 bool areAuthorShadowsAllowed() const final { return false; }
286 288
287 bool supportsFocus() const final; 289 bool supportsFocus() const final;
288 bool isMouseFocusable() const final; 290 bool isMouseFocusable() const final;
289 bool layoutObjectIsNeeded(const ComputedStyle&) override; 291 bool layoutObjectIsNeeded(const ComputedStyle&) override;
290 LayoutObject* createLayoutObject(const ComputedStyle&) override; 292 LayoutObject* createLayoutObject(const ComputedStyle&) override;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); 378 void deferredLoadTimerFired(Timer<HTMLMediaElement>*);
377 379
378 void markCaptionAndSubtitleTracksAsUnconfigured(); 380 void markCaptionAndSubtitleTracksAsUnconfigured();
379 381
380 // This does not check user gesture restrictions. 382 // This does not check user gesture restrictions.
381 void playInternal(); 383 void playInternal();
382 384
383 // This does not change the buffering strategy. 385 // This does not change the buffering strategy.
384 void pauseInternal(); 386 void pauseInternal();
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 getDirectionOfPlayback() const; 423 DirectionOfPlayback getDirectionOfPlayback() 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;
438
439 // If the user gesture is required, then this will remove it. Note that
440 // one should not generally call this method directly; use the one on
441 // m_helper and give it a reason.
446 void removeUserGestureRequirement(); 442 void removeUserGestureRequirement();
447 void setInitialPlayWithoutUserGestures(bool);
448 443
449 void setNetworkState(NetworkState); 444 void setNetworkState(NetworkState);
450 445
451 void audioTracksTimerFired(Timer<HTMLMediaElement>*); 446 void audioTracksTimerFired(Timer<HTMLMediaElement>*);
452 447
453 // TODO(liberato): remove once autoplay gesture override experiment conclude s. 448 // TODO(liberato): remove once autoplay gesture override experiment conclude s.
454 void triggerAutoplayViewportCheckForTesting(); 449 void triggerAutoplayViewportCheckForTesting();
455 450
456 void scheduleResolvePlayPromises(); 451 void scheduleResolvePlayPromises();
457 void scheduleRejectPlayPromises(ExceptionCode); 452 void scheduleRejectPlayPromises(ExceptionCode);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 547
553 bool m_closedCaptionsVisible : 1; 548 bool m_closedCaptionsVisible : 1;
554 549
555 bool m_havePreparedToPlay : 1; 550 bool m_havePreparedToPlay : 1;
556 551
557 bool m_tracksAreReady : 1; 552 bool m_tracksAreReady : 1;
558 bool m_processingPreferenceChange : 1; 553 bool m_processingPreferenceChange : 1;
559 bool m_remoteRoutesAvailable : 1; 554 bool m_remoteRoutesAvailable : 1;
560 bool m_playingRemotely : 1; 555 bool m_playingRemotely : 1;
561 bool m_isFinalizing : 1; 556 bool m_isFinalizing : 1;
562 bool m_initialPlayWithoutUserGesture : 1;
563 bool m_autoplayMediaCounted : 1;
564 // Whether this element is in overlay fullscreen mode. 557 // Whether this element is in overlay fullscreen mode.
565 bool m_inOverlayFullscreenVideo : 1; 558 bool m_inOverlayFullscreenVideo : 1;
566 559
567 PersistentWillBeMember<AudioTrackList> m_audioTracks; 560 PersistentWillBeMember<AudioTrackList> m_audioTracks;
568 PersistentWillBeMember<VideoTrackList> m_videoTracks; 561 PersistentWillBeMember<VideoTrackList> m_videoTracks;
569 PersistentWillBeMember<TextTrackList> m_textTracks; 562 PersistentWillBeMember<TextTrackList> m_textTracks;
570 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; 563 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan;
571 564
572 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; 565 OwnPtrWillBeMember<CueTimeline> m_cueTimeline;
573 566
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 DECLARE_TRACE(); 616 DECLARE_TRACE();
624 617
625 private: 618 private:
626 WebAudioSourceProvider* m_webAudioSourceProvider; 619 WebAudioSourceProvider* m_webAudioSourceProvider;
627 PersistentWillBeMember<AudioClientImpl> m_client; 620 PersistentWillBeMember<AudioClientImpl> m_client;
628 Mutex provideInputLock; 621 Mutex provideInputLock;
629 }; 622 };
630 623
631 AudioSourceProviderImpl m_audioSourceProvider; 624 AudioSourceProviderImpl m_audioSourceProvider;
632 625
626 class AutoplayHelperClientImpl;
627
633 friend class Internals; 628 friend class Internals;
634 friend class TrackDisplayUpdateScope; 629 friend class TrackDisplayUpdateScope;
635 friend class AutoplayExperimentHelper; 630 friend class AutoplayExperimentHelper;
636 friend class MediaControlsTest; 631 friend class MediaControlsTest;
637 632
638 AutoplayExperimentHelper m_autoplayHelper; 633 OwnPtrWillBeMember<AutoplayExperimentHelper::Client> m_autoplayHelperClient;
634 OwnPtrWillBeMember<AutoplayExperimentHelper> m_autoplayHelper;
639 635
640 static URLRegistry* s_mediaStreamRegistry; 636 static URLRegistry* s_mediaStreamRegistry;
641 }; 637 };
642 638
643 inline bool isHTMLMediaElement(const HTMLElement& element) 639 inline bool isHTMLMediaElement(const HTMLElement& element)
644 { 640 {
645 return isHTMLAudioElement(element) || isHTMLVideoElement(element); 641 return isHTMLAudioElement(element) || isHTMLVideoElement(element);
646 } 642 }
647 643
648 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); 644 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement);
649 645
650 } // namespace blink 646 } // namespace blink
651 647
652 #endif // HTMLMediaElement_h 648 #endif // HTMLMediaElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698