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

Unified Diff: third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp

Issue 1762103002: Keep ScriptProcessorNode from premature GC with ScriptWrappable::hasPendingActivity() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed the manual test and fixed the exisiting automated 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/ScriptProcessorNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp b/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
index c89091f0dfac76474c1472229371e3b76102f30a..7274ba1d0e680d96cc362cc48ce55a9bd16b0400 100644
--- a/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
@@ -294,5 +294,19 @@ size_t ScriptProcessorNode::bufferSize() const
return static_cast<ScriptProcessorHandler&>(handler()).bufferSize();
}
+bool ScriptProcessorNode::hasPendingActivity() const
+{
+ // To prevent the node from leaking after the context is closed.
+ if (context()->isContextClosed())
+ return false;
+
+ // If |onaudioprocess| event handler is defined, the node should not be
+ // GCed even if it is out of scope.
+ if (hasEventListeners(EventTypeNames::audioprocess))
+ return true;
+
+ return false;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698