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

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

Issue 15338009: Move workers to Chromium threading (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove extra assert Created 7 years, 7 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 | « Source/core/workers/WorkerThread.h ('k') | public/platform/WebThread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerThread.cpp
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index bc6a8a064635ee680b445ef388870018c315ec70..c82f9d2545427d44db44adda8625765754d6780c 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -33,6 +33,7 @@
#include "core/inspector/InspectorInstrumentation.h"
#include "core/platform/KURL.h"
#include "core/platform/ThreadGlobalData.h"
+#include "core/platform/Task.h"
#include "core/workers/DedicatedWorkerContext.h"
#include "modules/webdatabase/DatabaseManager.h"
#include "modules/webdatabase/DatabaseTask.h"
@@ -103,8 +104,7 @@ WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const St
}
WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
- : m_threadID(0)
- , m_workerLoaderProxy(workerLoaderProxy)
+ : m_workerLoaderProxy(workerLoaderProxy)
, m_workerReportingProxy(workerReportingProxy)
, m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin))
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
@@ -124,20 +124,15 @@ WorkerThread::~WorkerThread()
bool WorkerThread::start()
{
- // Mutex protection is necessary to ensure that m_threadID is initialized when the thread starts.
+ // Mutex protection is necessary to ensure that m_thread is initialized when the thread starts.
MutexLocker lock(m_threadCreationMutex);
- if (m_threadID)
+ if (m_thread)
return true;
- m_threadID = createThread(WorkerThread::workerThreadStart, this, "WebCore: Worker");
-
- return m_threadID;
-}
-
-void WorkerThread::workerThreadStart(void* thread)
-{
- static_cast<WorkerThread*>(thread)->workerThread();
+ m_thread = adoptPtr(WebKit::Platform::current()->createThread("WebCore: Worker"));
+ m_thread->postTask(new Task(bind(&WorkerThread::workerThread, this)));
+ return true;
}
void WorkerThread::workerThread()
@@ -166,8 +161,6 @@ void WorkerThread::workerThread()
runEventLoop();
- ThreadIdentifier threadID = m_threadID;
-
ASSERT(m_workerContext->hasOneRef());
// The below assignment will destroy the context, which will in turn notify messaging proxy.
@@ -176,9 +169,6 @@ void WorkerThread::workerThread()
// Clean up WebCore::ThreadGlobalData before WTF::WTFThreadData goes away!
threadGlobalData().destroy();
-
- // The thread object may be already destroyed from notification now, don't try to access "this".
- detachThread(threadID);
jamesr 2013/05/20 20:56:29 hmm, should we make an explicit effort to kill the
abarth-chromium 2013/05/20 21:00:36 Yes, I tried for a while having this code release(
}
void WorkerThread::runEventLoop()
@@ -258,6 +248,11 @@ void WorkerThread::stop()
m_runLoop.terminate();
}
+bool WorkerThread::isCurrentThread() const
+{
+ return m_thread->isCurrentThread();
+}
+
class ReleaseFastMallocFreeMemoryTask : public ScriptExecutionContext::Task {
virtual void performTask(ScriptExecutionContext*) OVERRIDE { WTF::releaseFastMallocFreeMemory(); }
};
« no previous file with comments | « Source/core/workers/WorkerThread.h ('k') | public/platform/WebThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698