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

Unified 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: Cleaning up test 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.cpp b/third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.cpp
index 8823d9dbdba8cc94ef11b5ff2bd0dbb5b946adf1..460eded87107012bf84d023c665254aa1fe80be3 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioScheduledSourceNode.cpp
@@ -263,5 +263,17 @@ void AudioScheduledSourceNode::setOnended(PassRefPtrWillBeRawPtr<EventListener>
setAttributeEventListener(EventTypeNames::ended, listener);
}
+bool AudioScheduledSourceNode::hasPendingActivity() const
+{
+ // To avoid the leak, a node should be collected regardless of its
+ // playback state if the context is closed.
+ if (context()->isContextClosed())
+ return false;
+
+ // If a node is scheduled or playing, do not collect the node prematurely
+ // even its reference is out of scope. Then fire onended event if assigned.
+ return audioScheduledSourceHandler().isPlayingOrScheduled();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698