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

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: 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 7853ed9487b53cff814c08256a0c8e5a031f7d97..c06458b60be6b810c8146fd6cc217f562985aa2d 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*>& aliveWebEmbeddedWorkerImplInstances()
michaeln 2014/07/25 02:49:52 this is long'ish, runningWorkerInstances()?
kouhei (in TOK) 2014/07/25 05:00:39 Acknowledged.
+{
+ 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)
{
+ aliveWebEmbeddedWorkerImplInstances().add(this);
}
WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl()
{
+ ASSERT(aliveWebEmbeddedWorkerImplInstances().contains(this));
+ aliveWebEmbeddedWorkerImplInstances().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 = aliveWebEmbeddedWorkerImplInstances();
+ 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