Changeset 224030 in webkit


Ignore:
Timestamp:
Oct 26, 2017 11:38:54 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Add inspector logging for MediaElementSession autoplay
https://bugs.webkit.org/show_bug.cgi?id=178846

Patch by Youenn Fablet <youenn@apple.com> on 2017-10-26
Reviewed by Eric Carlson.

No change of behavior.
Making use of pal Logger in MediaElementSession.
This new logging is limited to autoplay/playback for now.

  • html/MediaElementSession.cpp:

(WebCore::MediaElementSession::MediaElementSession):
(WebCore::MediaElementSession::playbackPermitted const):
(WebCore::MediaElementSession::autoplayPermitted const):
(WebCore::MediaElementSession::willLog const):
(WebCore::MediaElementSession::logChannel const):

  • html/MediaElementSession.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224027 r224030  
     12017-10-26  Youenn Fablet  <youenn@apple.com>
     2
     3        Add inspector logging for MediaElementSession autoplay
     4        https://bugs.webkit.org/show_bug.cgi?id=178846
     5
     6        Reviewed by Eric Carlson.
     7
     8        No change of behavior.
     9        Making use of pal Logger in MediaElementSession.
     10        This new logging is limited to autoplay/playback for now.
     11
     12        * html/MediaElementSession.cpp:
     13        (WebCore::MediaElementSession::MediaElementSession):
     14        (WebCore::MediaElementSession::playbackPermitted const):
     15        (WebCore::MediaElementSession::autoplayPermitted const):
     16        (WebCore::MediaElementSession::willLog const):
     17        (WebCore::MediaElementSession::logChannel const):
     18        * html/MediaElementSession.h:
     19
    1202017-10-26  Keith Miller  <keith_miller@apple.com>
    221
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r223960 r224030  
    542542    const PAL::Logger& logger() const final { return *m_logger.get(); }
    543543    const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
    544 #endif
     544    WTFLogChannel& logChannel() const final;
     545#endif
     546
     547    bool willLog(WTFLogLevel) const;
    545548
    546549protected:
     
    903906#if !RELEASE_LOG_DISABLED
    904907    const char* logClassName() const final { return "HTMLMediaElement"; }
    905     WTFLogChannel& logChannel() const final;
    906908
    907909    const void* mediaPlayerLogIdentifier() final { return logIdentifier(); }
    908910    const PAL::Logger& mediaPlayerLogger() final { return logger(); }
    909911#endif
    910 
    911     bool willLog(WTFLogLevel) const;
    912912
    913913    WeakPtrFactory<HTMLMediaElement> m_weakFactory;
  • trunk/Source/WebCore/html/MediaElementSession.cpp

    r223644 r224030  
    170170
    171171    if (requiresFullscreenForVideoPlayback(element) && !fullscreenPermitted(element)) {
    172         RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of fullscreen restriction");
     172        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because of fullscreen restriction");
    173173        return MediaPlaybackDenialReason::FullscreenRequired;
    174174    }
     
    197197
    198198    if (m_restrictions & RequireUserGestureForVideoRateChange && element.isVideo() && !element.document().processingUserGestureForMedia()) {
    199         RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of video rate change restriction");
     199        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a user gesture is required for video rate change restriction");
    200200        return MediaPlaybackDenialReason::UserGestureRequired;
    201201    }
    202202
    203203    if (m_restrictions & RequireUserGestureForAudioRateChange && (!element.isVideo() || element.hasAudio()) && !element.muted() && element.volume() && !element.document().processingUserGestureForMedia()) {
    204         RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of audio rate change restriction");
     204        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a user gesture is required for audio rate change restriction");
    205205        return MediaPlaybackDenialReason::UserGestureRequired;
    206206    }
    207207
    208208    if (m_restrictions & RequireUserGestureForVideoDueToLowPowerMode && element.isVideo() && !element.document().processingUserGestureForMedia()) {
    209         RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of video low power mode restriction");
     209        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because of video low power mode restriction");
    210210        return MediaPlaybackDenialReason::UserGestureRequired;
    211211    }
     
    230230
    231231    auto* renderer = m_element.renderer();
    232     if (!renderer)
    233         return false;
    234     if (renderer->style().visibility() != VISIBLE)
    235         return false;
    236     if (renderer->view().frameView().isOffscreen())
    237         return false;
    238     if (renderer->visibleInViewportState() != VisibleInViewportState::Yes)
    239         return false;
     232    if (!renderer) {
     233        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because element has no renderer");
     234        return false;
     235    }
     236    if (renderer->style().visibility() != VISIBLE) {
     237        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because element is not visible");
     238        return false;
     239    }
     240    if (renderer->view().frameView().isOffscreen()) {
     241        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because frame is offscreen");
     242        return false;
     243    }
     244    if (renderer->visibleInViewportState() != VisibleInViewportState::Yes) {
     245        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because element is not visible in the viewport");
     246        return false;
     247    }
    240248    return true;
    241249}
     
    832840}
    833841
     842bool MediaElementSession::willLog(WTFLogLevel level) const
     843{
     844    return m_element.willLog(level);
     845}
     846
     847#if !RELEASE_LOG_DISABLED
     848const PAL::Logger& MediaElementSession::logger() const
     849{
     850    return m_element.logger();
     851}
     852
     853const void* MediaElementSession::logIdentifier() const
     854{
     855    return m_element.logIdentifier();
     856}
     857
     858WTFLogChannel& MediaElementSession::logChannel() const
     859{
     860    return m_element.logChannel();
     861}
     862#endif
     863
    834864}
    835865
  • trunk/Source/WebCore/html/MediaElementSession.h

    r223728 r224030  
    3333#include "SuccessOr.h"
    3434#include "Timer.h"
     35#include <pal/LoggerHelper.h>
    3536#include <wtf/TypeCasts.h>
    3637
     
    5253class SourceBuffer;
    5354
    54 class MediaElementSession final : public PlatformMediaSession {
     55class MediaElementSession final : public PlatformMediaSession
     56#if !RELEASE_LOG_DISABLED
     57    , public PAL::LoggerHelper
     58#endif
     59    {
    5560    WTF_MAKE_FAST_ALLOCATED;
    5661public:
     
    144149    }
    145150
     151#if !RELEASE_LOG_DISABLED
     152    const PAL::Logger& logger() const final;
     153    const void* logIdentifier() const final;
     154    const char* logClassName() const final { return "MediaElementSession"; }
     155    WTFLogChannel& logChannel() const final;
     156#endif
     157    bool willLog(WTFLogLevel) const;
     158
    146159private:
    147160
Note: See TracChangeset for help on using the changeset viewer.