Chromium Code Reviews| Index: Source/modules/webaudio/AudioScheduledSourceNode.cpp |
| diff --git a/Source/modules/webaudio/AudioScheduledSourceNode.cpp b/Source/modules/webaudio/AudioScheduledSourceNode.cpp |
| index 39e06e752610f0a599276debad244fa76455983c..072873155ef241052f6f560a18a203b6418e440c 100644 |
| --- a/Source/modules/webaudio/AudioScheduledSourceNode.cpp |
| +++ b/Source/modules/webaudio/AudioScheduledSourceNode.cpp |
| @@ -42,10 +42,12 @@ const double AudioScheduledSourceNode::UnknownTime = -1; |
| AudioScheduledSourceNode::AudioScheduledSourceNode(AudioContext* context, float sampleRate) |
| : AudioSourceNode(context, sampleRate) |
| + , ActiveDOMObject(context->scriptExecutionContext()) |
| , m_playbackState(UNSCHEDULED_STATE) |
| , m_startTime(0) |
| , m_endTime(UnknownTime) |
| , m_hasEndedListener(false) |
| + , m_notifyingEndedListener(false) |
| { |
| } |
| @@ -144,7 +146,7 @@ void AudioScheduledSourceNode::start(double when) |
| m_playbackState = SCHEDULED_STATE; |
| } |
| -void AudioScheduledSourceNode::stop(double when) |
| +void AudioScheduledSourceNode::stopNote(double when) |
| { |
| ASSERT(isMainThread()); |
| if (!(m_playbackState == SCHEDULED_STATE || m_playbackState == PLAYING_STATE)) |
| @@ -161,7 +163,7 @@ void AudioScheduledSourceNode::noteOn(double when) |
| void AudioScheduledSourceNode::noteOff(double when) |
| { |
| - stop(when); |
| + stopNote(when); |
| } |
| void AudioScheduledSourceNode::setOnended(PassRefPtr<EventListener> listener, DOMWrapperWorld* isolatedWorld) |
| @@ -180,8 +182,8 @@ void AudioScheduledSourceNode::finish() |
| } |
| if (m_hasEndedListener) { |
| - // Reference ourself so we don't accidentally get deleted before notifyEnded gets called. |
| - ref(); |
| + m_notifyingEndedListener = true; |
| + setPendingActivity(this); |
| callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this); |
| } |
| } |
| @@ -199,9 +201,19 @@ void AudioScheduledSourceNode::notifyEnded() |
| event->setTarget(this); |
| dispatchEvent(event.get()); |
| } |
| + m_notifyingEndedListener = false; |
| + unsetPendingActivity(this); |
| +} |
| - // Deref to match the ref() call in finish(); |
| - deref(); |
| +ScriptExecutionContext* AudioScheduledSourceNode::scriptExecutionContext() const |
| +{ |
| + return context()->scriptExecutionContext(); |
| +} |
| + |
| +void AudioScheduledSourceNode::stop() |
| +{ |
| + if (m_notifyingEndedListener) |
|
haraken
2013/09/09 17:58:51
How about just using hasPendingActivity() instead
Raymond Toy (Google)
2013/09/09 18:23:45
Done. m_notifyingEndedListener removed.
|
| + unsetPendingActivity(this); |
| } |
| } // namespace WebCore |