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

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

Issue 398293003: WebAudio: Remove AudioSchedulesSourceNode::NotifyEndedTask (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Check if executionContext is null Created 6 years, 5 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
diff --git a/Source/modules/webaudio/AudioScheduledSourceNode.cpp b/Source/modules/webaudio/AudioScheduledSourceNode.cpp
index 19bcc5ee2dd2249b9c07872117a8f3d454329df7..98e4d1bc1284a6dc0833d59bde6eeea7a01f011d 100644
--- a/Source/modules/webaudio/AudioScheduledSourceNode.cpp
+++ b/Source/modules/webaudio/AudioScheduledSourceNode.cpp
@@ -29,15 +29,23 @@
#include "modules/webaudio/AudioScheduledSourceNode.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/CrossThreadTask.h"
#include "core/dom/ExceptionCode.h"
#include "modules/EventModules.h"
#include "modules/webaudio/AudioContext.h"
#include "platform/audio/AudioUtilities.h"
-#include <algorithm>
#include "wtf/MathExtras.h"
+#include <algorithm>
namespace WebCore {
+#if !ENABLE(OILPAN)
+// We need a dedicated specialization for AudioScheduledSourceNode because it
+// doesn't inherit from RefCounted.
+template<> struct CrossThreadCopierBase<false, false, false, PassRefPtr<AudioScheduledSourceNode> > : public CrossThreadCopierPassThrough<PassRefPtr<AudioScheduledSourceNode> > {
+};
+#endif
+
const double AudioScheduledSourceNode::UnknownTime = -1;
AudioScheduledSourceNode::AudioScheduledSourceNode(AudioContext* context, float sampleRate)
@@ -179,30 +187,14 @@ void AudioScheduledSourceNode::finish()
m_playbackState = FINISHED_STATE;
}
- 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());
+ if (m_hasEndedListener && context()->executionContext()) {
+ context()->executionContext()->postTask(createCrossThreadTask(&AudioScheduledSourceNode::notifyEnded, PassRefPtrWillBeRawPtr<AudioScheduledSourceNode>(this)));
}
}
-void AudioScheduledSourceNode::notifyEndedDispatch(void* userData)
-{
- OwnPtr<NotifyEndedTask> task = adoptPtr(static_cast<NotifyEndedTask*>(userData));
-
- task->notifyEnded();
-}
-
-AudioScheduledSourceNode::NotifyEndedTask::NotifyEndedTask(PassRefPtr<AudioScheduledSourceNode> sourceNode)
- : m_scheduledNode(sourceNode)
-{
-}
-
-void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded()
+void AudioScheduledSourceNode::notifyEnded()
{
- RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::ended);
- event->setTarget(m_scheduledNode.get());
- m_scheduledNode->dispatchEvent(event.get());
+ dispatchEvent(Event::create(EventTypeNames::ended));
}
} // 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