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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/webaudio/AudioScheduledSourceNode.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 void AudioScheduledSourceNode::finish() 173 void AudioScheduledSourceNode::finish()
174 { 174 {
175 if (m_playbackState != FINISHED_STATE) { 175 if (m_playbackState != FINISHED_STATE) {
176 // Let the context dereference this AudioNode. 176 // Let the context dereference this AudioNode.
177 context()->notifyNodeFinishedProcessing(this); 177 context()->notifyNodeFinishedProcessing(this);
178 m_playbackState = FINISHED_STATE; 178 m_playbackState = FINISHED_STATE;
179 context()->decrementActiveSourceCount(); 179 context()->decrementActiveSourceCount();
180 } 180 }
181 181
182 if (m_hasEndedListener) 182 if (m_hasEndedListener) {
183 callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this); 183 // |task| will keep the AudioScheduledSourceNode alive until the listene r has been handled.
184 OwnPtr<NotifyEndedTask> task = adoptPtr(new NotifyEndedTask(this));
185 callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, task.le akPtr());
186 }
184 } 187 }
185 188
186 void AudioScheduledSourceNode::notifyEndedDispatch(void* userData) 189 void AudioScheduledSourceNode::notifyEndedDispatch(void* userData)
187 { 190 {
188 static_cast<AudioScheduledSourceNode*>(userData)->notifyEnded(); 191 OwnPtr<NotifyEndedTask> task = adoptPtr(static_cast<NotifyEndedTask*>(userDa ta));
192
193 task->notifyEnded();
189 } 194 }
190 195
191 void AudioScheduledSourceNode::notifyEnded() 196 AudioScheduledSourceNode::NotifyEndedTask::NotifyEndedTask(PassRefPtr<AudioSched uledSourceNode> sourceNode)
197 : m_scheduledNode(sourceNode)
198 {
199 }
200
201 void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded()
192 { 202 {
193 RefPtr<Event> event = Event::create(eventNames().endedEvent, FALSE, FALSE); 203 RefPtr<Event> event = Event::create(eventNames().endedEvent, FALSE, FALSE);
194 event->setTarget(this); 204 event->setTarget(m_scheduledNode);
195 dispatchEvent(event.get()); 205 m_scheduledNode->dispatchEvent(event.get());
196 } 206 }
197 207
198 } // namespace WebCore 208 } // namespace WebCore
199 209
200 #endif // ENABLE(WEB_AUDIO) 210 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« 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