WebKit Bugzilla
Attachment 340044 Details for
Bug 185376
: Update MediaSession to use release logging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for landing
bug-185376-20180509153610.patch (text/plain), 36.37 KB, created by
Eric Carlson
on 2018-05-09 15:36:11 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Eric Carlson
Created:
2018-05-09 15:36:11 PDT
Size:
36.37 KB
patch
obsolete
>Subversion Revision: 231437 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b20d52b4d02a2bbc126d85eb4cb6b53df23a60f0..0ccb46c59ed6068ddd9119c174393b99e14f7922 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,62 @@ >+2018-05-07 Eric Carlson <eric.carlson@apple.com> >+ >+ Update MediaSession to use release logging >+ https://bugs.webkit.org/show_bug.cgi?id=185376 >+ <rdar://problem/40022203> >+ >+ Reviewed by Youenn Fablet. >+ >+ No new tests, tested manually. >+ >+ * Modules/mediastream/MediaStream.h: hostingDocument() doesn't need to return a const Document. >+ * Modules/webaudio/AudioContext.cpp: >+ (WebCore::AudioContext::hostingDocument const): Ditto. >+ * Modules/webaudio/AudioContext.h: >+ >+ * html/HTMLMediaElement.h: Ditto. >+ >+ * html/MediaElementSession.cpp: >+ (WebCore::MediaElementSession::MediaElementSession): >+ (WebCore::MediaElementSession::addBehaviorRestriction): >+ (WebCore::MediaElementSession::removeBehaviorRestriction): >+ (WebCore::MediaElementSession::dataLoadingPermitted const): >+ (WebCore::MediaElementSession::fullscreenPermitted const): >+ (WebCore::MediaElementSession::pageAllowsDataLoading const): >+ (WebCore::MediaElementSession::pageAllowsPlaybackAfterResuming const): >+ (WebCore::MediaElementSession::canShowControlsManager const): >+ (WebCore::MediaElementSession::showPlaybackTargetPicker): >+ (WebCore::MediaElementSession::hasWirelessPlaybackTargets const): >+ (WebCore::MediaElementSession::wirelessVideoPlaybackDisabled const): >+ (WebCore::MediaElementSession::setWirelessVideoPlaybackDisabled): >+ (WebCore::MediaElementSession::setHasPlaybackTargetAvailabilityListeners): >+ (WebCore::MediaElementSession::externalOutputDeviceAvailableDidChange): >+ (WebCore::MediaElementSession::setShouldPlayToPlaybackTarget): >+ (WebCore::MediaElementSession::mediaEngineUpdated): >+ (WebCore::MediaElementSession::willLog const): Deleted. >+ (WebCore::MediaElementSession::logger const): Deleted. >+ (WebCore::MediaElementSession::logIdentifier const): Deleted. >+ (WebCore::MediaElementSession::logChannel const): Deleted. >+ * html/MediaElementSession.h: >+ >+ * platform/audio/PlatformMediaSession.cpp: >+ (WebCore::nextLogIdentifier): >+ (WebCore::convertEnumerationToString): >+ (WebCore::PlatformMediaSession::PlatformMediaSession): >+ (WebCore::PlatformMediaSession::setState): >+ (WebCore::PlatformMediaSession::beginInterruption): >+ (WebCore::PlatformMediaSession::endInterruption): >+ (WebCore::PlatformMediaSession::clientWillBeginAutoplaying): >+ (WebCore::PlatformMediaSession::clientWillPausePlayback): >+ (WebCore::PlatformMediaSession::pauseSession): >+ (WebCore::PlatformMediaSession::stopSession): >+ (WebCore::PlatformMediaSession::clientDataBufferingTimerFired): >+ (WebCore::PlatformMediaSession::logChannel const): >+ (WebCore::stateName): Deleted. >+ (WebCore::interruptionName): Deleted. >+ * platform/audio/PlatformMediaSession.h: >+ (WTF::LogArgument<WebCore::PlatformMediaSession::State>::toString): >+ (WTF::LogArgument<WebCore::PlatformMediaSession::InterruptionType>::toString): >+ > 2018-05-06 Zalan Bujtas <zalan@apple.com> > > [LFC] Add assertions for stale Display::Box geometry >diff --git a/Source/WebCore/Modules/mediastream/MediaStream.h b/Source/WebCore/Modules/mediastream/MediaStream.h >index f65d06d69007370186d74964feeeaac129e38b4a..1c1ae11b80e00b573c33ec24c3945115866ea455 100644 >--- a/Source/WebCore/Modules/mediastream/MediaStream.h >+++ b/Source/WebCore/Modules/mediastream/MediaStream.h >@@ -151,7 +151,7 @@ private: > bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const final { return false; } > String sourceApplicationIdentifier() const final; > bool canProduceAudio() const final; >- const Document* hostingDocument() const final { return document(); } >+ Document* hostingDocument() const final { return document(); } > bool processingUserGestureForMedia() const final; > > // ActiveDOMObject API. >diff --git a/Source/WebCore/Modules/webaudio/AudioContext.cpp b/Source/WebCore/Modules/webaudio/AudioContext.cpp >index 2c7410dfd747b06483b53bb11ca71caf84fbd534..1c0d48f76117604bdf72790b552744ec3d22d681 100644 >--- a/Source/WebCore/Modules/webaudio/AudioContext.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioContext.cpp >@@ -343,7 +343,7 @@ Document* AudioContext::document() const > return downcast<Document>(m_scriptExecutionContext); > } > >-const Document* AudioContext::hostingDocument() const >+Document* AudioContext::hostingDocument() const > { > return downcast<Document>(m_scriptExecutionContext); > } >diff --git a/Source/WebCore/Modules/webaudio/AudioContext.h b/Source/WebCore/Modules/webaudio/AudioContext.h >index 2b8a2b108cd0d1adfe8fb912bfed2d3f9a1c833f..e5e65c078e80ebbfd12f9a73a5f77f7d6b4e3a46 100644 >--- a/Source/WebCore/Modules/webaudio/AudioContext.h >+++ b/Source/WebCore/Modules/webaudio/AudioContext.h >@@ -89,7 +89,7 @@ public: > > Document* document() const; // ASSERTs if document no longer exists. > >- const Document* hostingDocument() const override; >+ Document* hostingDocument() const final; > > AudioDestinationNode* destination() { return m_destinationNode.get(); } > size_t currentSampleFrame() const { return m_destinationNode->currentSampleFrame(); } >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index ba9f59a77c27bb9e738397e3baf5ae0648b00503..4d1468dc757bcfe8fa207f0fcb8b02b6097e3904 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -198,7 +198,7 @@ public: > > bool inActiveDocument() const { return m_inActiveDocument; } > >- const Document* hostingDocument() const override { return &document(); } >+ Document* hostingDocument() const final { return &document(); } > > // DOM API > // error state >diff --git a/Source/WebCore/html/MediaElementSession.cpp b/Source/WebCore/html/MediaElementSession.cpp >index 6728af5bc42dd5f2228246862082837dda2cade7..34b3e86c2fc2327a730e541a1247bb4b5310c839 100644 >--- a/Source/WebCore/html/MediaElementSession.cpp >+++ b/Source/WebCore/html/MediaElementSession.cpp >@@ -61,8 +61,8 @@ static const Seconds elementMainContentCheckInterval { 250_ms }; > static bool isElementRectMostlyInMainFrame(const HTMLMediaElement&); > static bool isElementLargeEnoughForMainContent(const HTMLMediaElement&, MediaSessionMainContentPurpose); > >-#if !LOG_DISABLED >-static String restrictionName(MediaElementSession::BehaviorRestrictions restriction) >+#if !RELEASE_LOG_DISABLED >+static String restrictionNames(MediaElementSession::BehaviorRestrictions restriction) > { > StringBuilder restrictionBuilder; > #define CASE(restrictionType) \ >@@ -72,19 +72,23 @@ static String restrictionName(MediaElementSession::BehaviorRestrictions restrict > restrictionBuilder.append(#restrictionType); \ > } \ > >- CASE(NoRestrictions); >- CASE(RequireUserGestureForLoad); >- CASE(RequireUserGestureForVideoRateChange); >- CASE(RequireUserGestureForAudioRateChange); >- CASE(RequireUserGestureForFullscreen); >- CASE(RequirePageConsentToLoadMedia); >- CASE(RequirePageConsentToResumeMedia); >-#if ENABLE(WIRELESS_PLAYBACK_TARGET) >- CASE(RequireUserGestureToShowPlaybackTargetPicker); >- CASE(WirelessVideoPlaybackDisabled); >-#endif >- CASE(InvisibleAutoplayNotPermitted); >- CASE(OverrideUserGestureRequirementForMainContent); >+ CASE(NoRestrictions) >+ CASE(RequireUserGestureForLoad) >+ CASE(RequireUserGestureForVideoRateChange) >+ CASE(RequireUserGestureForAudioRateChange) >+ CASE(RequireUserGestureForFullscreen) >+ CASE(RequirePageConsentToLoadMedia) >+ CASE(RequirePageConsentToResumeMedia) >+ CASE(RequireUserGestureToShowPlaybackTargetPicker) >+ CASE(WirelessVideoPlaybackDisabled) >+ CASE(RequireUserGestureToAutoplayToExternalDevice) >+ CASE(MetadataPreloadingNotPermitted) >+ CASE(AutoPreloadingNotPermitted) >+ CASE(InvisibleAutoplayNotPermitted) >+ CASE(OverrideUserGestureRequirementForMainContent) >+ CASE(RequireUserGestureToControlControlsManager) >+ CASE(RequirePlaybackToControlControlsManager) >+ CASE(RequireUserGestureForVideoDueToLowPowerMode) > > return restrictionBuilder.toString(); > } >@@ -105,6 +109,9 @@ MediaElementSession::MediaElementSession(HTMLMediaElement& element) > , m_targetAvailabilityChangedTimer(*this, &MediaElementSession::targetAvailabilityChangedTimerFired) > #endif > , m_mainContentCheckTimer(*this, &MediaElementSession::mainContentCheckTimerFired) >+#if !RELEASE_LOG_DISABLED >+ , m_logIdentifier(element.logIdentifier()) >+#endif > { > } > >@@ -126,12 +133,14 @@ void MediaElementSession::unregisterWithDocument(Document& document) > #endif > } > >-void MediaElementSession::addBehaviorRestriction(BehaviorRestrictions restriction) >+void MediaElementSession::addBehaviorRestriction(BehaviorRestrictions restrictions) > { >- LOG(Media, "MediaElementSession::addBehaviorRestriction - adding %s", restrictionName(restriction).utf8().data()); >- m_restrictions |= restriction; >+ if (restrictions & ~m_restrictions) >+ INFO_LOG(LOGIDENTIFIER, "adding ", restrictionNames(restrictions & ~m_restrictions)); >+ >+ m_restrictions |= restrictions; > >- if (restriction & OverrideUserGestureRequirementForMainContent) >+ if (restrictions & OverrideUserGestureRequirementForMainContent) > m_mainContentCheckTimer.startRepeating(elementMainContentCheckInterval); > } > >@@ -143,7 +152,10 @@ void MediaElementSession::removeBehaviorRestriction(BehaviorRestrictions restric > page->setAllowsPlaybackControlsForAutoplayingAudio(true); > } > >- LOG(Media, "MediaElementSession::removeBehaviorRestriction - removing %s", restrictionName(restriction).utf8().data()); >+ if (!(m_restrictions & restriction)) >+ return; >+ >+ INFO_LOG(LOGIDENTIFIER, "removing ", restrictionNames(m_restrictions & restriction)); > m_restrictions &= ~restriction; > } > >@@ -256,7 +268,7 @@ bool MediaElementSession::dataLoadingPermitted() const > return true; > > if (m_restrictions & RequireUserGestureForLoad && !m_element.document().processingUserGestureForMedia()) { >- LOG(Media, "MediaElementSession::dataLoadingPermitted - returning FALSE"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE"); > return false; > } > >@@ -266,7 +278,7 @@ bool MediaElementSession::dataLoadingPermitted() const > bool MediaElementSession::fullscreenPermitted() const > { > if (m_restrictions & RequireUserGestureForFullscreen && !m_element.document().processingUserGestureForMedia()) { >- LOG(Media, "MediaElementSession::fullscreenPermitted - returning FALSE"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE"); > return false; > } > >@@ -277,7 +289,7 @@ bool MediaElementSession::pageAllowsDataLoading() const > { > Page* page = m_element.document().page(); > if (m_restrictions & RequirePageConsentToLoadMedia && page && !page->canStartMedia()) { >- LOG(Media, "MediaElementSession::pageAllowsDataLoading - returning FALSE"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE"); > return false; > } > >@@ -288,7 +300,7 @@ bool MediaElementSession::pageAllowsPlaybackAfterResuming() const > { > Page* page = m_element.document().page(); > if (m_restrictions & RequirePageConsentToResumeMedia && page && !page->canStartMedia()) { >- LOG(Media, "MediaElementSession::pageAllowsPlaybackAfterResuming - returning FALSE"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE"); > return false; > } > >@@ -298,94 +310,94 @@ bool MediaElementSession::pageAllowsPlaybackAfterResuming() const > bool MediaElementSession::canShowControlsManager(PlaybackControlsPurpose purpose) const > { > if (m_element.isSuspended() || !m_element.inActiveDocument()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: isSuspended()"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: isSuspended()"); > return false; > } > > if (m_element.isFullscreen()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is fullscreen"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: is fullscreen"); > return true; > } > > if (m_element.muted()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Muted"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: muted"); > return false; > } > > if (m_element.document().isMediaDocument() && (m_element.document().frame() && m_element.document().frame()->isMainFrame())) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is media document"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: is media document"); > return true; > } > > if (client().presentationType() == Audio) { > if (!hasBehaviorRestriction(RequireUserGestureToControlControlsManager) || m_element.document().processingUserGestureForMedia()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Audio element with user gesture"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: audio element with user gesture"); > return true; > } > > if (m_element.isPlaying() && allowsPlaybackControlsForAutoplayingAudio()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: User has played media before"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: user has played media before"); > return true; > } > >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Audio element is not suitable"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: audio element is not suitable"); > return false; > } > > if (purpose == PlaybackControlsPurpose::ControlsManager && !isElementRectMostlyInMainFrame(m_element)) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Not in main frame"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: not in main frame"); > return false; > } > > if (!m_element.hasAudio() && !m_element.hasEverHadAudio()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No audio"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no audio"); > return false; > } > > if (!playbackPermitted()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Playback not permitted"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: playback not permitted"); > return false; > } > > if (!hasBehaviorRestriction(RequireUserGestureToControlControlsManager) || m_element.document().processingUserGestureForMedia()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: No user gesture required"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: no user gesture required"); > return true; > } > > if (purpose == PlaybackControlsPurpose::ControlsManager && hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Needs to be playing"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: needs to be playing"); > return false; > } > > if (!m_element.hasEverNotifiedAboutPlaying()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Hasn't fired playing notification"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: hasn't fired playing notification"); > return false; > } > > // Only allow the main content heuristic to forbid videos from showing up if our purpose is the controls manager. > if (purpose == PlaybackControlsPurpose::ControlsManager && m_element.isVideo()) { > if (!m_element.renderer()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No renderer"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no renderer"); > return false; > } > > if (!m_element.hasVideo() && !m_element.hasEverHadVideo()) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No video"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no video"); > return false; > } > > if (isLargeEnoughForMainContent(MediaSessionMainContentPurpose::MediaControls)) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Is main content"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: is main content"); > return true; > } > } > > if (purpose == PlaybackControlsPurpose::NowPlaying) { >- LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Potentially plays audio"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE: potentially plays audio"); > return true; > } > >- LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No user gesture"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE: no user gesture"); > return false; > } > >@@ -414,22 +426,22 @@ bool MediaElementSession::wantsToObserveViewportVisibilityForAutoplay() const > #if ENABLE(WIRELESS_PLAYBACK_TARGET) > void MediaElementSession::showPlaybackTargetPicker() > { >- LOG(Media, "MediaElementSession::showPlaybackTargetPicker"); >+ INFO_LOG(LOGIDENTIFIER); > > auto& document = m_element.document(); > if (m_restrictions & RequireUserGestureToShowPlaybackTargetPicker && !document.processingUserGestureForMedia()) { >- LOG(Media, "MediaElementSession::showPlaybackTargetPicker - returning early because of permissions"); >+ INFO_LOG(LOGIDENTIFIER, "returning early because of permissions"); > return; > } > > if (!document.page()) { >- LOG(Media, "MediaElementSession::showingPlaybackTargetPickerPermitted - returning early because page is NULL"); >+ INFO_LOG(LOGIDENTIFIER, "returning early because page is NULL"); > return; > } > > #if !PLATFORM(IOS) > if (m_element.readyState() < HTMLMediaElementEnums::HAVE_METADATA) { >- LOG(Media, "MediaElementSession::showPlaybackTargetPicker - returning early because element is not playable"); >+ INFO_LOG(LOGIDENTIFIER, "returning early because element is not playable"); > return; > } > #endif >@@ -445,7 +457,7 @@ bool MediaElementSession::hasWirelessPlaybackTargets() const > m_hasPlaybackTargets = PlatformMediaSessionManager::sharedManager().hasWirelessTargetsAvailable(); > #endif > >- LOG(Media, "MediaElementSession::hasWirelessPlaybackTargets - returning %s", m_hasPlaybackTargets ? "TRUE" : "FALSE"); >+ INFO_LOG(LOGIDENTIFIER, "returning ", m_hasPlaybackTargets); > > return m_hasPlaybackTargets; > } >@@ -453,23 +465,23 @@ bool MediaElementSession::hasWirelessPlaybackTargets() const > bool MediaElementSession::wirelessVideoPlaybackDisabled() const > { > if (!m_element.document().settings().allowsAirPlayForMediaPlayback()) { >- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of settings"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE because of settings"); > return true; > } > > if (m_element.hasAttributeWithoutSynchronization(HTMLNames::webkitwirelessvideoplaybackdisabledAttr)) { >- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of attribute"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE because of attribute"); > return true; > } > > #if PLATFORM(IOS) > auto& legacyAirplayAttributeValue = m_element.attributeWithoutSynchronization(HTMLNames::webkitairplayAttr); > if (equalLettersIgnoringASCIICase(legacyAirplayAttributeValue, "deny")) { >- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning TRUE because of legacy attribute"); >+ INFO_LOG(LOGIDENTIFIER, "returning TRUE because of legacy attribute"); > return true; > } > if (equalLettersIgnoringASCIICase(legacyAirplayAttributeValue, "allow")) { >- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning FALSE because of legacy attribute"); >+ INFO_LOG(LOGIDENTIFIER, "returning FALSE because of legacy attribute"); > return false; > } > #endif >@@ -479,7 +491,7 @@ bool MediaElementSession::wirelessVideoPlaybackDisabled() const > return true; > > bool disabled = player->wirelessVideoPlaybackDisabled(); >- LOG(Media, "MediaElementSession::wirelessVideoPlaybackDisabled - returning %s because media engine says so", disabled ? "TRUE" : "FALSE"); >+ INFO_LOG(LOGIDENTIFIER, "returning ", disabled, " because media engine says so"); > > return disabled; > } >@@ -495,13 +507,13 @@ void MediaElementSession::setWirelessVideoPlaybackDisabled(bool disabled) > if (!player) > return; > >- LOG(Media, "MediaElementSession::setWirelessVideoPlaybackDisabled - disabled %s", disabled ? "TRUE" : "FALSE"); >+ INFO_LOG(LOGIDENTIFIER, disabled); > player->setWirelessVideoPlaybackDisabled(disabled); > } > > void MediaElementSession::setHasPlaybackTargetAvailabilityListeners(bool hasListeners) > { >- LOG(Media, "MediaElementSession::setHasPlaybackTargetAvailabilityListeners - hasListeners %s", hasListeners ? "TRUE" : "FALSE"); >+ INFO_LOG(LOGIDENTIFIER, hasListeners); > > #if PLATFORM(IOS) > m_hasPlaybackTargetAvailabilityListeners = hasListeners; >@@ -528,7 +540,7 @@ void MediaElementSession::externalOutputDeviceAvailableDidChange(bool hasTargets > if (m_hasPlaybackTargets == hasTargets) > return; > >- LOG(Media, "MediaElementSession::externalOutputDeviceAvailableDidChange(%p) - hasTargets %s", this, hasTargets ? "TRUE" : "FALSE"); >+ INFO_LOG(LOGIDENTIFIER, hasTargets); > > m_hasPlaybackTargets = hasTargets; > m_targetAvailabilityChangedTimer.startOneShot(0_s); >@@ -556,7 +568,7 @@ bool MediaElementSession::isPlayingToWirelessPlaybackTarget() const > > void MediaElementSession::setShouldPlayToPlaybackTarget(bool shouldPlay) > { >- LOG(Media, "MediaElementSession::setShouldPlayToPlaybackTarget - shouldPlay %s", shouldPlay ? "TRUE" : "FALSE"); >+ INFO_LOG(LOGIDENTIFIER, shouldPlay); > m_shouldPlayToPlaybackTarget = shouldPlay; > client().setShouldPlayToPlaybackTarget(shouldPlay); > } >@@ -635,7 +647,7 @@ bool MediaElementSession::allowsAutomaticMediaDataLoading() const > > void MediaElementSession::mediaEngineUpdated() > { >- LOG(Media, "MediaElementSession::mediaEngineUpdated"); >+ INFO_LOG(LOGIDENTIFIER); > > #if ENABLE(WIRELESS_PLAYBACK_TARGET) > if (m_restrictions & WirelessVideoPlaybackDisabled) >@@ -843,28 +855,6 @@ bool MediaElementSession::allowsPlaybackControlsForAutoplayingAudio() const > return page && page->allowsPlaybackControlsForAutoplayingAudio(); > } > >-bool MediaElementSession::willLog(WTFLogLevel level) const >-{ >- return m_element.willLog(level); >-} >- >-#if !RELEASE_LOG_DISABLED >-const 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) >diff --git a/Source/WebCore/html/MediaElementSession.h b/Source/WebCore/html/MediaElementSession.h >index 31af7604b964ac9b397a1d7fd59de485722b798f..8289ffa3fb52f572881d1a846d2f5a6070898774 100644 >--- a/Source/WebCore/html/MediaElementSession.h >+++ b/Source/WebCore/html/MediaElementSession.h >@@ -32,7 +32,6 @@ > #include "PlatformMediaSession.h" > #include "SuccessOr.h" > #include "Timer.h" >-#include <wtf/LoggerHelper.h> > #include <wtf/TypeCasts.h> > > namespace WebCore { >@@ -53,9 +52,6 @@ class HTMLMediaElement; > class SourceBuffer; > > class MediaElementSession final : public PlatformMediaSession >-#if !RELEASE_LOG_DISABLED >- , private LoggerHelper >-#endif > { > WTF_MAKE_FAST_ALLOCATED; > public: >@@ -149,12 +145,9 @@ public: > } > > #if !RELEASE_LOG_DISABLED >- const Logger& logger() const final; >- const void* logIdentifier() const final; >+ const void* logIdentifier() const final { return m_logIdentifier; } > const char* logClassName() const final { return "MediaElementSession"; } >- WTFLogChannel& logChannel() const final; > #endif >- bool willLog(WTFLogLevel) const; > > private: > >@@ -189,6 +182,10 @@ private: > > mutable bool m_isMainContent { false }; > Timer m_mainContentCheckTimer; >+ >+#if !RELEASE_LOG_DISABLED >+ const void* m_logIdentifier; >+#endif > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/audio/PlatformMediaSession.cpp b/Source/WebCore/platform/audio/PlatformMediaSession.cpp >index 27ab225f38da450fc8884e4c93c7c8518703ae4d..f2e19827b4655a9217f629e131981527467987d4 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSession.cpp >+++ b/Source/WebCore/platform/audio/PlatformMediaSession.cpp >@@ -31,43 +31,59 @@ > #include "Logging.h" > #include "MediaPlayer.h" > #include "PlatformMediaSessionManager.h" >+#include <wtf/CryptographicallyRandomNumber.h> > > namespace WebCore { > > static const Seconds clientDataBufferingTimerThrottleDelay { 100_ms }; > >-#if !LOG_DISABLED >-static const char* stateName(PlatformMediaSession::State state) >-{ >-#define STATE_CASE(state) case PlatformMediaSession::state: return #state >- switch (state) { >- STATE_CASE(Idle); >- STATE_CASE(Autoplaying); >- STATE_CASE(Playing); >- STATE_CASE(Paused); >- STATE_CASE(Interrupted); >- } >- >- ASSERT_NOT_REACHED(); >- return ""; >+#if !RELEASE_LOG_DISABLED >+static uint64_t nextLogIdentifier() >+{ >+ static uint64_t logIdentifier = cryptographicallyRandomNumber(); >+ return ++logIdentifier; >+} >+ >+String convertEnumerationToString(PlatformMediaSession::State state) >+{ >+ static const NeverDestroyed<String> values[] = { >+ MAKE_STATIC_STRING_IMPL("Idle"), >+ MAKE_STATIC_STRING_IMPL("Autoplaying"), >+ MAKE_STATIC_STRING_IMPL("Playing"), >+ MAKE_STATIC_STRING_IMPL("Paused"), >+ MAKE_STATIC_STRING_IMPL("Interrupted"), >+ }; >+ static_assert(!static_cast<size_t>(PlatformMediaSession::Idle), "PlatformMediaSession::Idle is not 0 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::Autoplaying == 1), "PlatformMediaSession::Autoplaying is not 1 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::Playing == 2), "PlatformMediaSession::Playing is not 2 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::Paused == 3), "PlatformMediaSession::Paused is not 3 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::Interrupted == 4), "PlatformMediaSession::Interrupted is not 4 as expected"); >+ ASSERT(static_cast<size_t>(state) < WTF_ARRAY_LENGTH(values)); >+ return values[static_cast<size_t>(state)]; >+} >+ >+String convertEnumerationToString(PlatformMediaSession::InterruptionType type) >+{ >+ static const NeverDestroyed<String> values[] = { >+ MAKE_STATIC_STRING_IMPL("NoInterruption"), >+ MAKE_STATIC_STRING_IMPL("SystemSleep"), >+ MAKE_STATIC_STRING_IMPL("EnteringBackground"), >+ MAKE_STATIC_STRING_IMPL("SystemInterruption"), >+ MAKE_STATIC_STRING_IMPL("SuspendedUnderLock"), >+ MAKE_STATIC_STRING_IMPL("InvisibleAutoplay"), >+ MAKE_STATIC_STRING_IMPL("ProcessInactive"), >+ }; >+ static_assert(!static_cast<size_t>(PlatformMediaSession::NoInterruption), "PlatformMediaSession::NoInterruption is not 0 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::SystemSleep == 1), "PlatformMediaSession::SystemSleep is not 1 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::EnteringBackground == 2), "PlatformMediaSession::EnteringBackground is not 2 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::SystemInterruption == 3), "PlatformMediaSession::SystemInterruption is not 3 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::SuspendedUnderLock == 4), "PlatformMediaSession::SuspendedUnderLock is not 4 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::InvisibleAutoplay == 5), "PlatformMediaSession::InvisibleAutoplay is not 5 as expected"); >+ static_assert(static_cast<size_t>(PlatformMediaSession::ProcessInactive == 6), "PlatformMediaSession::ProcessInactive is not 6 as expected"); >+ ASSERT(static_cast<size_t>(type) < WTF_ARRAY_LENGTH(values)); >+ return values[static_cast<size_t>(type)]; > } > >-static const char* interruptionName(PlatformMediaSession::InterruptionType type) >-{ >-#define INTERRUPTION_CASE(type) case PlatformMediaSession::type: return #type >- switch (type) { >- INTERRUPTION_CASE(NoInterruption); >- INTERRUPTION_CASE(SystemSleep); >- INTERRUPTION_CASE(EnteringBackground); >- INTERRUPTION_CASE(SystemInterruption); >- INTERRUPTION_CASE(SuspendedUnderLock); >- INTERRUPTION_CASE(InvisibleAutoplay); >- INTERRUPTION_CASE(ProcessInactive); >- } >- >- ASSERT_NOT_REACHED(); >- return ""; >-} > #endif > > std::unique_ptr<PlatformMediaSession> PlatformMediaSession::create(PlatformMediaSessionClient& client) >@@ -81,6 +97,10 @@ PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionClient& client) > , m_state(Idle) > , m_stateToRestore(Idle) > , m_notifyingClient(false) >+#if !RELEASE_LOG_DISABLED >+ , m_logger(client.hostingDocument()->logger()) >+ , m_logIdentifier(nextLogIdentifier()) >+#endif > { > ASSERT(m_client.mediaType() >= None && m_client.mediaType() <= MediaStreamCapturingAudio); > PlatformMediaSessionManager::sharedManager().addSession(*this); >@@ -93,13 +113,13 @@ PlatformMediaSession::~PlatformMediaSession() > > void PlatformMediaSession::setState(State state) > { >- LOG(Media, "PlatformMediaSession::setState(%p) - %s", this, stateName(state)); >+ INFO_LOG(LOGIDENTIFIER, state); > m_state = state; > } > > void PlatformMediaSession::beginInterruption(InterruptionType type) > { >- LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount); >+ INFO_LOG(LOGIDENTIFIER, "state = ", m_state, ", interruption type = ", type, ", interruption count = ", m_interruptionCount); > > // When interruptions are overridden, m_interruptionType doesn't get set. > // Give nested interruptions a chance when the previous interruptions were overridden. >@@ -107,7 +127,7 @@ void PlatformMediaSession::beginInterruption(InterruptionType type) > return; > > if (client().shouldOverrideBackgroundPlaybackRestriction(type)) { >- LOG(Media, "PlatformMediaSession::beginInterruption(%p), returning early because client says to override interruption", this); >+ INFO_LOG(LOGIDENTIFIER, "returning early because client says to override interruption"); > return; > } > >@@ -121,10 +141,10 @@ void PlatformMediaSession::beginInterruption(InterruptionType type) > > void PlatformMediaSession::endInterruption(EndInterruptionFlags flags) > { >- LOG(Media, "PlatformMediaSession::endInterruption(%p) - flags = %i, stateToRestore = %s, interruption count = %i", this, (int)flags, stateName(m_stateToRestore), m_interruptionCount); >+ INFO_LOG(LOGIDENTIFIER, "flags = ", (int)flags, ", stateToRestore = ", m_stateToRestore, ", interruption count = ", m_interruptionCount); > > if (!m_interruptionCount) { >- LOG(Media, "PlatformMediaSession::endInterruption(%p) - !! ignoring spurious interruption end !!", this); >+ INFO_LOG(LOGIDENTIFIER, "!! ignoring spurious interruption end !!"); > return; > } > >@@ -148,10 +168,10 @@ void PlatformMediaSession::clientWillBeginAutoplaying() > if (m_notifyingClient) > return; > >- LOG(Media, "PlatformMediaSession::clientWillBeginAutoplaying(%p)- state = %s", this, stateName(m_state)); >+ INFO_LOG(LOGIDENTIFIER, "state = ", m_state); > if (state() == Interrupted) { > m_stateToRestore = Autoplaying; >- LOG(Media, " setting stateToRestore to \"Autoplaying\""); >+ INFO_LOG(LOGIDENTIFIER, " setting stateToRestore to \"Autoplaying\""); > return; > } > >@@ -180,10 +200,10 @@ bool PlatformMediaSession::clientWillPausePlayback() > if (m_notifyingClient) > return true; > >- LOG(Media, "PlatformMediaSession::clientWillPausePlayback(%p)- state = %s", this, stateName(m_state)); >+ INFO_LOG(LOGIDENTIFIER, "state = ", m_state); > if (state() == Interrupted) { > m_stateToRestore = Paused; >- LOG(Media, " setting stateToRestore to \"Paused\""); >+ INFO_LOG(LOGIDENTIFIER, " setting stateToRestore to \"Paused\""); > return false; > } > >@@ -195,13 +215,13 @@ bool PlatformMediaSession::clientWillPausePlayback() > > void PlatformMediaSession::pauseSession() > { >- LOG(Media, "PlatformMediaSession::pauseSession(%p)", this); >+ INFO_LOG(LOGIDENTIFIER); > m_client.suspendPlayback(); > } > > void PlatformMediaSession::stopSession() > { >- LOG(Media, "PlatformMediaSession::stopSession(%p)", this); >+ INFO_LOG(LOGIDENTIFIER); > m_client.suspendPlayback(); > PlatformMediaSessionManager::sharedManager().removeSession(*this); > } >@@ -266,7 +286,7 @@ void PlatformMediaSession::scheduleClientDataBufferingCheck() > > void PlatformMediaSession::clientDataBufferingTimerFired() > { >- LOG(Media, "PlatformMediaSession::clientDataBufferingTimerFired(%p)- visible = %s", this, m_client.elementIsHidden() ? "false" : "true"); >+ INFO_LOG(LOGIDENTIFIER, "visible = ", m_client.elementIsHidden()); > > updateClientDataBuffering(); > >@@ -370,5 +390,13 @@ void PlatformMediaSession::clientCharacteristicsChanged() > PlatformMediaSessionManager::sharedManager().clientCharacteristicsChanged(*this); > } > >+#if !RELEASE_LOG_DISABLED >+WTFLogChannel& PlatformMediaSession::logChannel() const >+{ >+ return LogMedia; >+} >+#endif >+ > } >+ > #endif >diff --git a/Source/WebCore/platform/audio/PlatformMediaSession.h b/Source/WebCore/platform/audio/PlatformMediaSession.h >index ec58ab60b40afcba26ba9a5b6c787031491e2ad7..838e34737bdce7d4e389b82092531bc84604eb0e 100644 >--- a/Source/WebCore/platform/audio/PlatformMediaSession.h >+++ b/Source/WebCore/platform/audio/PlatformMediaSession.h >@@ -27,6 +27,7 @@ > #define PlatformMediaSession_h > > #include "Timer.h" >+#include <wtf/LoggerHelper.h> > #include <wtf/Noncopyable.h> > #include <wtf/text/WTFString.h> > >@@ -44,6 +45,9 @@ class PlatformMediaSession > #if ENABLE(WIRELESS_PLAYBACK_TARGET) > : public MediaPlaybackTargetClient > #endif >+#if !RELEASE_LOG_DISABLED >+ , private LoggerHelper >+#endif > { > public: > static std::unique_ptr<PlatformMediaSession> create(PlatformMediaSessionClient&); >@@ -176,6 +180,13 @@ public: > protected: > PlatformMediaSessionClient& client() const { return m_client; } > >+#if !RELEASE_LOG_DISABLED >+ const Logger& logger() const final { return m_logger.get(); } >+ const void* logIdentifier() const override { return reinterpret_cast<const void*>(m_logIdentifier); } >+ const char* logClassName() const override { return "PlatformMediaSession"; } >+ WTFLogChannel& logChannel() const final; >+#endif >+ > private: > void clientDataBufferingTimerFired(); > void updateClientDataBuffering(); >@@ -189,6 +200,11 @@ private: > bool m_notifyingClient; > bool m_isPlayingToWirelessPlaybackTarget { false }; > >+#if !RELEASE_LOG_DISABLED >+ Ref<const Logger> m_logger; >+ uint64_t m_logIdentifier; >+#endif >+ > friend class PlatformMediaSessionManager; > }; > >@@ -230,7 +246,7 @@ public: > virtual bool isPlayingToWirelessPlaybackTarget() const { return false; } > virtual void setShouldPlayToPlaybackTarget(bool) { } > >- virtual const Document* hostingDocument() const = 0; >+ virtual Document* hostingDocument() const = 0; > virtual String sourceApplicationIdentifier() const = 0; > > virtual bool processingUserGestureForMedia() const = 0; >@@ -239,6 +255,32 @@ protected: > virtual ~PlatformMediaSessionClient() = default; > }; > >+String convertEnumerationToString(PlatformMediaSession::State); >+String convertEnumerationToString(PlatformMediaSession::InterruptionType); >+ > } > >+namespace WTF { >+ >+template<typename Type> >+struct LogArgument; >+ >+template <> >+struct LogArgument<WebCore::PlatformMediaSession::State> { >+ static String toString(const WebCore::PlatformMediaSession::State state) >+ { >+ return convertEnumerationToString(state); >+ } >+}; >+ >+template <> >+struct LogArgument<WebCore::PlatformMediaSession::InterruptionType> { >+ static String toString(const WebCore::PlatformMediaSession::InterruptionType state) >+ { >+ return convertEnumerationToString(state); >+ } >+}; >+ >+} // namespace WTF >+ > #endif // PlatformMediaSession_h
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185376
:
339716
|
339723
| 340044