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

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

Issue 432673003: Revert of Change WokerThread to use a blink::WebThread (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
« no previous file with comments | « Source/core/workers/WorkerRunLoop.cpp ('k') | Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/WorkerThread.h
diff --git a/Source/core/workers/WorkerThread.h b/Source/core/workers/WorkerThread.h
index 2dccd35e0ef97c02496a1b0fbd1cd4b56e8d8264..deb0028e77ccda3d21b431cfbdad5558145386a4 100644
--- a/Source/core/workers/WorkerThread.h
+++ b/Source/core/workers/WorkerThread.h
@@ -27,14 +27,10 @@
#ifndef WorkerThread_h
#define WorkerThread_h
-#include "core/dom/ExecutionContextTask.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
-#include "core/workers/WorkerGlobalScope.h"
-#include "platform/SharedTimer.h"
+#include "core/workers/WorkerRunLoop.h"
#include "platform/weborigin/SecurityOrigin.h"
-#include "public/platform/WebThread.h"
#include "wtf/Forward.h"
-#include "wtf/MessageQueue.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
@@ -47,49 +43,39 @@
class KURL;
class WorkerGlobalScope;
- class WorkerInspectorController;
class WorkerLoaderProxy;
class WorkerReportingProxy;
- class WorkerSharedTimer;
- class WorkerThreadShutdownFinishTask;
class WorkerThreadStartupData;
- class WorkerThreadTask;
+ class WorkerInspectorController;
enum WorkerThreadStartMode { DontPauseWorkerGlobalScopeOnStart, PauseWorkerGlobalScopeOnStart };
-
class WorkerThread : public RefCounted<WorkerThread> {
public:
virtual ~WorkerThread();
- virtual void start();
- virtual void stop();
+ bool start();
+ void stop();
// Can be used to wait for this worker thread to shut down.
// (This is signalled on the main thread, so it's assumed to be waited on the worker context thread)
blink::WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); }
bool isCurrentThread() const;
+ WorkerRunLoop& runLoop() { return m_runLoop; }
WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
WorkerReportingProxy& workerReportingProxy() const { return m_workerReportingProxy; }
void postTask(PassOwnPtr<ExecutionContextTask>);
void postDebuggerTask(PassOwnPtr<ExecutionContextTask>);
- enum WaitMode { WaitForMessage, DontWaitForMessage };
- MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage);
-
- // These methods should be called if the holder of the thread is
- // going to call runDebuggerTask in a loop.
- void willEnterNestedLoop();
- void didLeaveNestedLoop();
-
- blink::WebThread* webThread() { return m_thread.get(); }
- WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.get(); }
- bool terminated() const { return m_terminated; }
+ MessageQueueWaitResult runDebuggerTask(WorkerRunLoop::WaitMode = WorkerRunLoop::WaitForMessage);
+ bool terminated() { return m_runLoop.terminated(); }
// Number of active worker threads.
static unsigned workerThreadCount();
+
+ WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope.get(); }
void interruptAndDispatchInspectorCommands();
void setWorkerInspectorController(WorkerInspectorController*);
@@ -100,31 +86,27 @@
// Factory method for creating a new worker context for the thread.
virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0;
- virtual void postInitialize() { }
+ // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
+ virtual void runEventLoop();
private:
- friend class WorkerThreadShutdownFinishTask;
+ // Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
+ static void workerThreadStart(void*);
- void initialize();
- void cleanup();
- void idleHandler();
+ void workerThread();
- bool m_terminated;
- OwnPtr<blink::WebThread> m_thread;
- OwnPtr<WorkerSharedTimer> m_sharedTimer;
- MessageQueue<WorkerThreadTask> m_debuggerMessageQueue;
-
+ ThreadIdentifier m_threadID;
+ WorkerRunLoop m_runLoop;
WorkerLoaderProxy& m_workerLoaderProxy;
WorkerReportingProxy& m_workerReportingProxy;
+
+ RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
+ Mutex m_threadCreationMutex;
RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorController;
Mutex m_workerInspectorControllerMutex;
- Mutex m_threadCreationMutex;
- RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
OwnPtrWillBePersistent<WorkerThreadStartupData> m_startupData;
-
- OwnPtr<WeakPtrFactory<WorkerThread> > m_weakFactory;
// Used to signal thread shutdown.
OwnPtr<blink::WebWaitableEvent> m_shutdownEvent;
« no previous file with comments | « Source/core/workers/WorkerRunLoop.cpp ('k') | Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698