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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.cpp

Issue 1593763002: Keep AudioSourceNode from premature GC with ScriptWrappable::hasPendingActivity() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify changes (-AbstractAudioContext) Created 4 years, 10 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
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 AudioScheduledSourceNode::AudioScheduledSourceNode(AbstractAudioContext& context ) 226 AudioScheduledSourceNode::AudioScheduledSourceNode(AbstractAudioContext& context )
227 : AudioSourceNode(context) 227 : AudioSourceNode(context)
228 { 228 {
229 } 229 }
230 230
231 AudioScheduledSourceHandler& AudioScheduledSourceNode::audioScheduledSourceHandl er() const 231 AudioScheduledSourceHandler& AudioScheduledSourceNode::audioScheduledSourceHandl er() const
232 { 232 {
233 return static_cast<AudioScheduledSourceHandler&>(handler()); 233 return static_cast<AudioScheduledSourceHandler&>(handler());
234 } 234 }
235 235
236 void AudioScheduledSourceNode::start(ExceptionState& exceptionState) 236 void AudioScheduledSourceNode::startNode(ExceptionState& exceptionState)
237 { 237 {
238 start(0, exceptionState); 238 startNode(0, exceptionState);
239 } 239 }
240 240
241 void AudioScheduledSourceNode::start(double when, ExceptionState& exceptionState ) 241 void AudioScheduledSourceNode::startNode(double when, ExceptionState& exceptionS tate)
242 { 242 {
243 audioScheduledSourceHandler().start(when, exceptionState); 243 audioScheduledSourceHandler().start(when, exceptionState);
244 } 244 }
245 245
246 void AudioScheduledSourceNode::stop(ExceptionState& exceptionState) 246 void AudioScheduledSourceNode::stopNode(ExceptionState& exceptionState)
247 { 247 {
248 stop(0, exceptionState); 248 stopNode(0, exceptionState);
249 } 249 }
250 250
251 void AudioScheduledSourceNode::stop(double when, ExceptionState& exceptionState) 251 void AudioScheduledSourceNode::stopNode(double when, ExceptionState& exceptionSt ate)
252 { 252 {
253 audioScheduledSourceHandler().stop(when, exceptionState); 253 audioScheduledSourceHandler().stop(when, exceptionState);
254 } 254 }
255 255
256 EventListener* AudioScheduledSourceNode::onended() 256 EventListener* AudioScheduledSourceNode::onended()
257 { 257 {
258 return getAttributeEventListener(EventTypeNames::ended); 258 return getAttributeEventListener(EventTypeNames::ended);
259 } 259 }
260 260
261 void AudioScheduledSourceNode::setOnended(PassRefPtrWillBeRawPtr<EventListener> listener) 261 void AudioScheduledSourceNode::setOnended(PassRefPtrWillBeRawPtr<EventListener> listener)
262 { 262 {
263 setAttributeEventListener(EventTypeNames::ended, listener); 263 setAttributeEventListener(EventTypeNames::ended, listener);
264 } 264 }
265 265
266 bool AudioScheduledSourceNode::hasPendingActivity() const
267 {
268 // It is possible to play a source node for a very long time or to schedule
269 // too far in the future; thus infinitely playing/scheduled sources leak
270 // after the execution context is torn down because |hasPendingActivity|
271 // still returns true.
Raymond Toy 2016/02/22 17:43:51 Don't think this comment really adds anything. I
hongchan 2016/02/23 18:01:33 Where is the comment at line 173?
Raymond Toy 2016/02/23 18:12:05 Oops. 273, the lines below.
272 //
273 // To avoid the leak, a node should be collected regardless of its
274 // playback state if the context is closed.
275 if (context()->isContextClosed())
276 return false;
277
278 // If a node is scheduled or playing, do not collect the node prematurely
279 // even its reference is out of scope. (and fire onended event if assigned)
Raymond Toy 2016/02/22 17:43:51 Typo: "(and fire" -> "And fire".
hongchan 2016/02/23 18:01:33 Done.
280 return audioScheduledSourceHandler().isPlayingOrScheduled();
281 }
282
266 } // namespace blink 283 } // namespace blink
267 284
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698