Index: Source/core/workers/WorkerMessagingProxy.cpp |
diff --git a/Source/core/workers/WorkerMessagingProxy.cpp b/Source/core/workers/WorkerMessagingProxy.cpp |
index 228b63f2c06ab3701369fcccec7e8befc0ea8e05..2305a09d16256ec913558b9d830deea28c3d90d7 100644 |
--- a/Source/core/workers/WorkerMessagingProxy.cpp |
+++ b/Source/core/workers/WorkerMessagingProxy.cpp |
@@ -81,13 +81,18 @@ WorkerMessagingProxy::WorkerMessagingProxy(InProcessWorkerBase* workerObject, Pa |
ASSERT((m_executionContext->isDocument() && isMainThread()) |
|| (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_executionContext.get())->thread()->isCurrentThread())); |
m_workerInspectorProxy->setWorkerGlobalScopeProxy(this); |
+#if ENABLE(OILPAN) |
+ m_keepAlive = adoptPtr(new Persistent<WorkerMessagingProxy>(this)); |
+#endif |
} |
WorkerMessagingProxy::~WorkerMessagingProxy() |
{ |
ASSERT(!m_workerObject); |
+#if !ENABLE(OILPAN) |
ASSERT((m_executionContext->isDocument() && isMainThread()) |
|| (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_executionContext.get())->thread()->isCurrentThread())); |
+#endif |
if (m_loaderProxy) |
m_loaderProxy->detachProvider(this); |
} |
@@ -222,8 +227,13 @@ void WorkerMessagingProxy::workerThreadTerminated() |
m_askedToTerminate = true; |
m_workerThread = nullptr; |
terminateInternally(); |
- if (m_mayBeDestroyed) |
+ if (m_mayBeDestroyed) { |
+#if ENABLE(OILPAN) |
+ m_keepAlive.release(); |
+#else |
delete this; |
+#endif |
+ } |
} |
void WorkerMessagingProxy::terminateWorkerGlobalScope() |
@@ -292,4 +302,19 @@ void WorkerMessagingProxy::terminateInternally() |
frame->console().adoptWorkerMessagesAfterTermination(this); |
} |
+void WorkerMessagingProxy::clearWeakMembers(Visitor* visitor) |
+{ |
+ if (Heap::isHeapObjectAlive(m_workerObject)) |
+ return; |
+ workerObjectDestroyed(); |
haraken
2015/07/30 11:46:31
It is not nice to call workerObjectDestroyed() in
|
+} |
+ |
+DEFINE_TRACE(WorkerMessagingProxy) |
+{ |
+ visitor->trace(m_executionContext); |
+ visitor->trace(m_workerClients); |
+ visitor->template registerWeakMembers<WorkerMessagingProxy, &WorkerMessagingProxy::clearWeakMembers>(this); |
+ WorkerGlobalScopeProxy::trace(visitor); |
+} |
+ |
} // namespace blink |