Title: [224030] trunk/Source/WebCore
Revision
224030
Author
[email protected]
Date
2017-10-26 11:38:54 -0700 (Thu, 26 Oct 2017)

Log Message

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

Patch by Youenn Fablet <[email protected]> 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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224029 => 224030)


--- trunk/Source/WebCore/ChangeLog	2017-10-26 18:20:14 UTC (rev 224029)
+++ trunk/Source/WebCore/ChangeLog	2017-10-26 18:38:54 UTC (rev 224030)
@@ -1,3 +1,22 @@
+2017-10-26  Youenn Fablet  <[email protected]>
+
+        Add inspector logging for MediaElementSession autoplay
+        https://bugs.webkit.org/show_bug.cgi?id=178846
+
+        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:
+
 2017-10-26  Keith Miller  <[email protected]>
 
         Move ApplePay to unified sources

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (224029 => 224030)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2017-10-26 18:20:14 UTC (rev 224029)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2017-10-26 18:38:54 UTC (rev 224030)
@@ -541,8 +541,11 @@
 #if !RELEASE_LOG_DISABLED
     const PAL::Logger& logger() const final { return *m_logger.get(); }
     const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
+    WTFLogChannel& logChannel() const final;
 #endif
 
+    bool willLog(WTFLogLevel) const;
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
     virtual void finishInitialization();
@@ -902,14 +905,11 @@
 
 #if !RELEASE_LOG_DISABLED
     const char* logClassName() const final { return "HTMLMediaElement"; }
-    WTFLogChannel& logChannel() const final;
 
     const void* mediaPlayerLogIdentifier() final { return logIdentifier(); }
     const PAL::Logger& mediaPlayerLogger() final { return logger(); }
 #endif
 
-    bool willLog(WTFLogLevel) const;
-
     WeakPtrFactory<HTMLMediaElement> m_weakFactory;
     Timer m_pendingActionTimer;
     Timer m_progressEventTimer;

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (224029 => 224030)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2017-10-26 18:20:14 UTC (rev 224029)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2017-10-26 18:38:54 UTC (rev 224030)
@@ -169,7 +169,7 @@
         return { };
 
     if (requiresFullscreenForVideoPlayback(element) && !fullscreenPermitted(element)) {
-        RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of fullscreen restriction");
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because of fullscreen restriction");
         return MediaPlaybackDenialReason::FullscreenRequired;
     }
 
@@ -196,17 +196,17 @@
 #endif
 
     if (m_restrictions & RequireUserGestureForVideoRateChange && element.isVideo() && !element.document().processingUserGestureForMedia()) {
-        RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of video rate change restriction");
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a user gesture is required for video rate change restriction");
         return MediaPlaybackDenialReason::UserGestureRequired;
     }
 
     if (m_restrictions & RequireUserGestureForAudioRateChange && (!element.isVideo() || element.hasAudio()) && !element.muted() && element.volume() && !element.document().processingUserGestureForMedia()) {
-        RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of audio rate change restriction");
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because a user gesture is required for audio rate change restriction");
         return MediaPlaybackDenialReason::UserGestureRequired;
     }
 
     if (m_restrictions & RequireUserGestureForVideoDueToLowPowerMode && element.isVideo() && !element.document().processingUserGestureForMedia()) {
-        RELEASE_LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of video low power mode restriction");
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because of video low power mode restriction");
         return MediaPlaybackDenialReason::UserGestureRequired;
     }
 
@@ -229,14 +229,22 @@
         return true;
 
     auto* renderer = m_element.renderer();
-    if (!renderer)
+    if (!renderer) {
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because element has no renderer");
         return false;
-    if (renderer->style().visibility() != VISIBLE)
+    }
+    if (renderer->style().visibility() != VISIBLE) {
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because element is not visible");
         return false;
-    if (renderer->view().frameView().isOffscreen())
+    }
+    if (renderer->view().frameView().isOffscreen()) {
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because frame is offscreen");
         return false;
-    if (renderer->visibleInViewportState() != VisibleInViewportState::Yes)
+    }
+    if (renderer->visibleInViewportState() != VisibleInViewportState::Yes) {
+        ALWAYS_LOG(LOGIDENTIFIER, "Returning FALSE because element is not visible in the viewport");
         return false;
+    }
     return true;
 }
 
@@ -831,6 +839,28 @@
     return page && page->allowsPlaybackControlsForAutoplayingAudio();
 }
 
+bool MediaElementSession::willLog(WTFLogLevel level) const
+{
+    return m_element.willLog(level);
 }
 
+#if !RELEASE_LOG_DISABLED
+const PAL::Logger& MediaElementSession::logger() const
+{
+    return m_element.logger();
+}
+
+const void* MediaElementSession::logIdentifier() const
+{
+    return m_element.logIdentifier();
+}
+
+WTFLogChannel& MediaElementSession::logChannel() const
+{
+    return m_element.logChannel();
+}
+#endif
+
+}
+
 #endif // ENABLE(VIDEO)

Modified: trunk/Source/WebCore/html/MediaElementSession.h (224029 => 224030)


--- trunk/Source/WebCore/html/MediaElementSession.h	2017-10-26 18:20:14 UTC (rev 224029)
+++ trunk/Source/WebCore/html/MediaElementSession.h	2017-10-26 18:38:54 UTC (rev 224030)
@@ -32,6 +32,7 @@
 #include "PlatformMediaSession.h"
 #include "SuccessOr.h"
 #include "Timer.h"
+#include <pal/LoggerHelper.h>
 #include <wtf/TypeCasts.h>
 
 namespace WebCore {
@@ -51,7 +52,11 @@
 class HTMLMediaElement;
 class SourceBuffer;
 
-class MediaElementSession final : public PlatformMediaSession {
+class MediaElementSession final : public PlatformMediaSession
+#if !RELEASE_LOG_DISABLED
+    , public PAL::LoggerHelper
+#endif
+    {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     explicit MediaElementSession(HTMLMediaElement&);
@@ -143,6 +148,14 @@
             || type == VideoAudio;
     }
 
+#if !RELEASE_LOG_DISABLED
+    const PAL::Logger& logger() const final;
+    const void* logIdentifier() const final;
+    const char* logClassName() const final { return "MediaElementSession"; }
+    WTFLogChannel& logChannel() const final;
+#endif
+    bool willLog(WTFLogLevel) const;
+
 private:
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to