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

Unified Diff: Source/modules/webaudio/AudioScheduledSourceNode.cpp

Issue 23710047: Merge 157615 "Keep AudioScheduledSourceNode alive until onended ..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1599/
Patch Set: Created 7 years, 3 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/webaudio/AudioScheduledSourceNode.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioScheduledSourceNode.cpp
===================================================================
--- Source/modules/webaudio/AudioScheduledSourceNode.cpp (revision 157760)
+++ Source/modules/webaudio/AudioScheduledSourceNode.cpp (working copy)
@@ -179,20 +179,30 @@
context()->decrementActiveSourceCount();
}
- if (m_hasEndedListener)
- callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this);
+ if (m_hasEndedListener) {
+ // |task| will keep the AudioScheduledSourceNode alive until the listener has been handled.
+ OwnPtr<NotifyEndedTask> task = adoptPtr(new NotifyEndedTask(this));
+ callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, task.leakPtr());
+ }
}
void AudioScheduledSourceNode::notifyEndedDispatch(void* userData)
{
- static_cast<AudioScheduledSourceNode*>(userData)->notifyEnded();
+ OwnPtr<NotifyEndedTask> task = adoptPtr(static_cast<NotifyEndedTask*>(userData));
+
+ task->notifyEnded();
}
-void AudioScheduledSourceNode::notifyEnded()
+AudioScheduledSourceNode::NotifyEndedTask::NotifyEndedTask(PassRefPtr<AudioScheduledSourceNode> sourceNode)
+ : m_scheduledNode(sourceNode)
{
+}
+
+void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded()
+{
RefPtr<Event> event = Event::create(eventNames().endedEvent, FALSE, FALSE);
- event->setTarget(this);
- dispatchEvent(event.get());
+ event->setTarget(m_scheduledNode);
+ m_scheduledNode->dispatchEvent(event.get());
}
} // namespace WebCore
« no previous file with comments | « Source/modules/webaudio/AudioScheduledSourceNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698