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

Unified Diff: Source/core/workers/Worker.cpp

Issue 370553003: Have the Worker destructor handle non-started Workers better. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Swap lines; tidier. Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/Worker.cpp
diff --git a/Source/core/workers/Worker.cpp b/Source/core/workers/Worker.cpp
index f6056006676c2247d2535440e36e07b9036a83de..b3cf2ff133320a3bb653bd166356de79cc7105c1 100644
--- a/Source/core/workers/Worker.cpp
+++ b/Source/core/workers/Worker.cpp
@@ -82,9 +82,10 @@ PassRefPtrWillBeRawPtr<Worker> Worker::create(ExecutionContext* context, const S
Worker::~Worker()
{
ASSERT(isMainThread());
+ if (!m_contextProxy)
+ return;
ASSERT(executionContext()); // The context is protected by worker context proxy, so it cannot be destroyed while a Worker exists.
- if (m_contextProxy)
- m_contextProxy->workerObjectDestroyed();
+ m_contextProxy->workerObjectDestroyed();
}
const AtomicString& Worker::interfaceName() const
@@ -94,6 +95,7 @@ const AtomicString& Worker::interfaceName() const
void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionState)
{
+ ASSERT(m_contextProxy);
// Disentangle the port in preparation for sending it to the remote context.
OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, exceptionState);
if (exceptionState.hadException())
@@ -114,7 +116,7 @@ void Worker::stop()
bool Worker::hasPendingActivity() const
{
- return m_contextProxy->hasPendingActivity() || ActiveDOMObject::hasPendingActivity();
+ return (m_contextProxy && m_contextProxy->hasPendingActivity()) || ActiveDOMObject::hasPendingActivity();
}
void Worker::didReceiveResponse(unsigned long identifier, const ResourceResponse&)
@@ -127,6 +129,7 @@ void Worker::notifyFinished()
if (m_scriptLoader->failed()) {
dispatchEvent(Event::createCancelable(EventTypeNames::error));
} else {
+ ASSERT(m_contextProxy);
WorkerThreadStartMode startMode = DontPauseWorkerGlobalScopeOnStart;
if (InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(executionContext()))
startMode = PauseWorkerGlobalScopeOnStart;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698