WebKit Bugzilla
Attachment 370284 Details for
Bug 198060
: Make AudioContext and MediaStreamTrack privately derive from MediaProducer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198060-20190520170049.patch (text/plain), 11.09 KB, created by
youenn fablet
on 2019-05-20 17:00:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-05-20 17:00:49 PDT
Size:
11.09 KB
patch
obsolete
>Subversion Revision: 245470 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4234b1762b752b461b1fd4c53113f8a45afe38dc..05a214acc9bc438147f47a8dff4b9121fab8058d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,32 @@ >+2019-05-20 Youenn Fablet <youenn@apple.com> >+ >+ Make AudioContext and MediaStreamTrack privately derive from MediaProducer >+ https://bugs.webkit.org/show_bug.cgi?id=198060 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Creating a WeakPtr from a subclass is error prone. >+ Let's make MediaProducer inherit privately from CanMakeWeakPtr to limit the issue. >+ No change of behavior. >+ >+ * Modules/mediastream/MediaStreamTrack.cpp: >+ (WebCore::MediaStreamTrack::MediaStreamTrack): >+ (WebCore::MediaStreamTrack::~MediaStreamTrack): >+ (WebCore::MediaStreamTrack::applyConstraints): >+ * Modules/mediastream/MediaStreamTrack.h: >+ * Modules/webaudio/AudioContext.cpp: >+ (WebCore::AudioContext::AudioContext): >+ * Modules/webaudio/AudioContext.h: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * html/HTMLMediaElement.cpp: >+ (WebCore::HTMLMediaElement::registerWithDocument): >+ (WebCore::HTMLMediaElement::unregisterWithDocument): >+ * page/MediaProducer.cpp: Added. >+ (WebCore::MediaProducer::addToAudioProducers): >+ (WebCore::MediaProducer::removeFromAudioProducers): >+ * page/MediaProducer.h: >+ > 2019-05-17 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r245401. >diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >index 8399d879bab569a04c55f6431c857e321ae249dd..669d4f014939433245c0aa8b643cb1da82d40c18 100644 >--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >@@ -73,7 +73,7 @@ MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, Ref<MediaStr > m_private->addObserver(*this); > > if (auto document = this->document()) { >- document->addAudioProducer(*this); >+ addToAudioProducers(*document); > if (isCaptureTrack() && document->page() && document->page()->mutedState()) > setMuted(document->page()->mutedState()); > } >@@ -84,7 +84,7 @@ MediaStreamTrack::~MediaStreamTrack() > m_private->removeObserver(*this); > > if (auto document = this->document()) >- document->removeAudioProducer(*this); >+ removeFromAudioProducers(*document); > } > > const AtomicString& MediaStreamTrack::kind() const >@@ -365,7 +365,7 @@ void MediaStreamTrack::applyConstraints(const Optional<MediaTrackConstraints>& c > { > m_promise = WTFMove(promise); > >- auto completionHandler = [this, weakThis = makeWeakPtr(*this), constraints](auto&& error) mutable { >+ auto completionHandler = [this, weakThis = makeWeakPtr<MediaProducer>(*this), constraints](auto&& error) mutable { > if (!weakThis || !m_promise) > return; > if (error) { >diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.h b/Source/WebCore/Modules/mediastream/MediaStreamTrack.h >index de8b5a6f89fe88c44fa2c77638253c3086908331..6aa1a67cebfb43d139b1ab957604785907e6fd9e 100644 >--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.h >+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.h >@@ -51,7 +51,7 @@ class MediaStreamTrack > : public RefCounted<MediaStreamTrack> > , public ActiveDOMObject > , public EventTargetWithInlineData >- , public MediaProducer >+ , private MediaProducer > , private MediaStreamTrackPrivate::Observer > #if !RELEASE_LOG_DISABLED > , private LoggerHelper >diff --git a/Source/WebCore/Modules/webaudio/AudioContext.cpp b/Source/WebCore/Modules/webaudio/AudioContext.cpp >index 6aabd2b166e523703c2190c30cb8daa8f66098e7..82d2f9e22f6c0f22dc29aa4bd471d09715ff5e5f 100644 >--- a/Source/WebCore/Modules/webaudio/AudioContext.cpp >+++ b/Source/WebCore/Modules/webaudio/AudioContext.cpp >@@ -148,7 +148,7 @@ AudioContext::AudioContext(Document& document) > // Initialize the destination node's muted state to match the page's current muted state. > pageMutedStateDidChange(); > >- document.addAudioProducer(*this); >+ addToAudioProducers(document); > document.registerForVisibilityStateChangedCallbacks(*this); > } > >diff --git a/Source/WebCore/Modules/webaudio/AudioContext.h b/Source/WebCore/Modules/webaudio/AudioContext.h >index 5d790a47ed6c079f250e52e876ceeb8404a84181..f1ff44396aae4fb94eee99d29248f277ad581193 100644 >--- a/Source/WebCore/Modules/webaudio/AudioContext.h >+++ b/Source/WebCore/Modules/webaudio/AudioContext.h >@@ -85,7 +85,7 @@ class AudioContext > , public ThreadSafeRefCounted<AudioContext> > , public EventTargetWithInlineData > , public MediaCanStartListener >- , public MediaProducer >+ , private MediaProducer > , private PlatformMediaSessionClient > , private VisibilityChangeClient > #if !RELEASE_LOG_DISABLED >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index d026a8e27c9a46bf4758bbdd36a214e08699927e..fc9736918935734328829e929382976f4cad98e0 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1503,6 +1503,7 @@ page/History.cpp > page/IntersectionObserver.cpp > page/IntersectionObserverEntry.cpp > page/Location.cpp >+page/MediaProducer.cpp > page/MemoryRelease.cpp > page/MouseEventWithHitTestResults.cpp > page/Navigator.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index ac1e14488c9801f3b04e4ff9e847675219ba18c0..8f5887d9645f9bf896a40a7bc3aa1c4b065fa85f 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -7324,6 +7324,7 @@ > 41A023ED1A39DB7900F722DF /* WritableStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WritableStream.idl; sourceTree = "<group>"; }; > 41A0829922932EF4008426E0 /* FeaturePolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FeaturePolicy.h; sourceTree = "<group>"; }; > 41A0829B22932EF4008426E0 /* FeaturePolicy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FeaturePolicy.cpp; sourceTree = "<group>"; }; >+ 41A0829D229371E1008426E0 /* MediaProducer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaProducer.cpp; sourceTree = "<group>"; }; > 41A1B00D1E52656E007F3769 /* LibWebRTCProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCProvider.cpp; path = libwebrtc/LibWebRTCProvider.cpp; sourceTree = "<group>"; }; > 41A1B01A1E542396007F3769 /* JSDOMGuardedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMGuardedObject.h; sourceTree = "<group>"; }; > 41A1B01B1E542396007F3769 /* JSDOMGuardedObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGuardedObject.cpp; sourceTree = "<group>"; }; >@@ -20146,6 +20147,7 @@ > BCE1C4190D982980003B02F2 /* Location.h */, > BCE1C4220D9829F2003B02F2 /* Location.idl */, > 931BCC601124DFCB00BE70DD /* MediaCanStartListener.h */, >+ 41A0829D229371E1008426E0 /* MediaProducer.cpp */, > 52E2CAFB19FF0207001EEB4F /* MediaProducer.h */, > 413E00771DB0E4DE002341D2 /* MemoryRelease.cpp */, > 413E00781DB0E4DE002341D2 /* MemoryRelease.h */, >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 216e937236d980cfa08e49285ecb30779c44aedf..1aee24d0661f0d8077aeeeb8cf7bfdaaddc8c2cc 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -712,7 +712,7 @@ void HTMLMediaElement::registerWithDocument(Document& document) > > document.registerForAllowsMediaDocumentInlinePlaybackChangedCallbacks(*this); > >- document.addAudioProducer(*this); >+ addToAudioProducers(document); > addElementToDocumentMap(*this, document); > > #if ENABLE(MEDIA_STREAM) >@@ -753,7 +753,7 @@ void HTMLMediaElement::unregisterWithDocument(Document& document) > > document.unregisterForAllowsMediaDocumentInlinePlaybackChangedCallbacks(*this); > >- document.removeAudioProducer(*this); >+ removeFromAudioProducers(document); > removeElementFromDocumentMap(*this, document); > > #if ENABLE(MEDIA_STREAM) >diff --git a/Source/WebCore/page/MediaProducer.cpp b/Source/WebCore/page/MediaProducer.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7d36a88bab55854510c9262641c3cf487f78d859 >--- /dev/null >+++ b/Source/WebCore/page/MediaProducer.cpp >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "MediaProducer.h" >+ >+namespace WebCore { >+ >+void MediaProducer::addToAudioProducers(Document& document) >+{ >+ document.addAudioProducer(*this); >+} >+ >+void MediaProducer::removeFromAudioProducers(Document&) >+{ >+ document.removeAudioProducer(*this); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/page/MediaProducer.h b/Source/WebCore/page/MediaProducer.h >index 92c19e85c8d6d0d5209e1d35bd40b064857e014c..b08c843a3276dc3576a9857f5c99dfcc602c9f08 100644 >--- a/Source/WebCore/page/MediaProducer.h >+++ b/Source/WebCore/page/MediaProducer.h >@@ -29,7 +29,9 @@ > > namespace WebCore { > >-class MediaProducer : public CanMakeWeakPtr<MediaProducer> { >+class Document; >+ >+class MediaProducer : private CanMakeWeakPtr<MediaProducer> { > public: > enum MediaState { > IsNotPlaying = 0, >@@ -79,6 +81,11 @@ public: > > virtual void pageMutedStateDidChange() = 0; > >+ void addToAudioProducers(Document&); >+ void removeFromAudioProducers(Document&); >+ >+ friend WeakPtr<MediaProducer> WTF::makeWeakPtr<MediaProducer>(MediaProducer&); >+ > protected: > virtual ~MediaProducer() = default; > };
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 198060
:
370284
|
370285