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

Unified Diff: Source/web/WebEmbeddedWorkerImpl.cpp

Issue 413993002: LeakDetector: Terminate all WebEmbeddedWorkerImpl before counting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rename set Created 6 years, 5 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: Source/web/WebEmbeddedWorkerImpl.cpp
diff --git a/Source/web/WebEmbeddedWorkerImpl.cpp b/Source/web/WebEmbeddedWorkerImpl.cpp
index 71aac5f62281c14c80327b991808f800df9244ed..c28bd7802a4b9da135b37a7272218d2c9ab88c91 100644
--- a/Source/web/WebEmbeddedWorkerImpl.cpp
+++ b/Source/web/WebEmbeddedWorkerImpl.cpp
@@ -146,6 +146,12 @@ WebEmbeddedWorker* WebEmbeddedWorker::create(
return new WebEmbeddedWorkerImpl(adoptPtr(client), adoptPtr(permissionClient));
}
+static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances()
+{
+ DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ());
+ return set;
+}
+
WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(
PassOwnPtr<WebServiceWorkerContextClient> client,
PassOwnPtr<WebWorkerPermissionClientProxy> permissionClient)
@@ -156,10 +162,13 @@ WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(
, m_askedToTerminate(false)
, m_pauseAfterDownloadState(DontPauseAfterDownload)
{
+ runningWorkerInstances().add(this);
}
WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl()
{
+ ASSERT(runningWorkerInstances().contains(this));
+ runningWorkerInstances().remove(this);
ASSERT(m_webView);
// Detach the client before closing the view to avoid getting called back.
@@ -169,6 +178,14 @@ WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl()
m_mainFrame->close();
}
+void WebEmbeddedWorkerImpl::terminateAll()
+{
+ HashSet<WebEmbeddedWorkerImpl*> instances = runningWorkerInstances();
+ for (HashSet<WebEmbeddedWorkerImpl*>::iterator it = instances.begin(), itEnd = instances.end(); it != itEnd; ++it) {
+ (*it)->terminateWorkerContext();
+ }
+}
+
void WebEmbeddedWorkerImpl::startWorkerContext(
const WebEmbeddedWorkerStartData& data)
{

Powered by Google App Engine
This is Rietveld 408576698