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

Unified Diff: Source/modules/mediasource/MediaSource.cpp

Issue 363953002: Oilpan: have the media element safely close its MediaSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tidy clearing of m_attachedElement Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/SourceBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediasource/MediaSource.cpp
diff --git a/Source/modules/mediasource/MediaSource.cpp b/Source/modules/mediasource/MediaSource.cpp
index aa0a295c25867c84b0cc201706fd769ca934c6a0..6e0dae0bbcb055564a7f3d2370e31438b1fb1d22 100644
--- a/Source/modules/mediasource/MediaSource.cpp
+++ b/Source/modules/mediasource/MediaSource.cpp
@@ -98,7 +98,7 @@ MediaSource::MediaSource(ExecutionContext* context)
: ActiveDOMObject(context)
, m_readyState(closedKeyword())
, m_asyncEventQueue(GenericEventQueue::create(this))
- , m_attachedElement(0)
+ , m_attachedElement(nullptr)
, m_sourceBuffers(SourceBufferList::create(executionContext(), m_asyncEventQueue.get()))
, m_activeSourceBuffers(SourceBufferList::create(executionContext(), m_asyncEventQueue.get()))
{
@@ -109,7 +109,9 @@ MediaSource::MediaSource(ExecutionContext* context)
MediaSource::~MediaSource()
{
WTF_LOG(Media, "MediaSource::~MediaSource %p", this);
+#if !ENABLE(OILPAN)
ASSERT(isClosed());
+#endif
}
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& exceptionState)
@@ -257,6 +259,19 @@ ExecutionContext* MediaSource::executionContext() const
return ActiveDOMObject::executionContext();
}
+void MediaSource::clearWeakMembers(Visitor* visitor)
+{
+#if ENABLE(OILPAN)
+ // Oilpan: If the MediaSource survived, but its attached media
+ // element did not, signal the element that it can safely
+ // notify its MediaSource during finalization by calling close().
+ if (m_attachedElement && !visitor->isAlive(m_attachedElement)) {
+ m_attachedElement->setCloseMediaSourceWhenFinalizing();
+ m_attachedElement.clear();
+ }
+#endif
+}
+
void MediaSource::trace(Visitor* visitor)
{
#if ENABLE(OILPAN)
@@ -264,6 +279,7 @@ void MediaSource::trace(Visitor* visitor)
#endif
visitor->trace(m_sourceBuffers);
visitor->trace(m_activeSourceBuffers);
+ visitor->registerWeakMembers<MediaSource, &MediaSource::clearWeakMembers>(this);
EventTargetWithInlineData::trace(visitor);
}
@@ -403,7 +419,7 @@ void MediaSource::setReadyState(const AtomicString& state)
if (state == closedKeyword()) {
m_webMediaSource.clear();
- m_attachedElement = 0;
+ m_attachedElement.clear();
}
if (oldState == state)
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | Source/modules/mediasource/SourceBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698