| Index: Source/core/workers/WorkerThread.h
|
| diff --git a/Source/core/workers/WorkerThread.h b/Source/core/workers/WorkerThread.h
|
| index f1d083b1e768abdcbf4f0daa9be2c5610adc4de9..c3210df38e468b87322017e17d2305fd342799e6 100644
|
| --- a/Source/core/workers/WorkerThread.h
|
| +++ b/Source/core/workers/WorkerThread.h
|
| @@ -58,6 +58,33 @@ enum WorkerThreadStartMode {
|
| };
|
|
|
| class WorkerThread : public RefCounted<WorkerThread> {
|
| +
|
| + class WorkerThreadTask : public blink::WebThread::Task {
|
| + WTF_MAKE_NONCOPYABLE(WorkerThreadTask); WTF_MAKE_FAST_ALLOCATED;
|
| + public:
|
| + static PassOwnPtr<WorkerThreadTask> create(WorkerThread&
|
| + , PassOwnPtr<ExecutionContextTask>, bool);
|
| +
|
| + virtual ~WorkerThreadTask() { }
|
| + virtual void run() override;
|
| +
|
| + void setIsIdleHandlerTask(bool isIdleHandlerTask) { m_isIdleHandlerTask = isIdleHandlerTask; }
|
| + bool isIdleHandlerTask() const { return m_isIdleHandlerTask; }
|
| + void cancelTask() { m_isTaskCanceled = true; };
|
| + double creationTimeStamp() const { return m_timeStamp; }
|
| +
|
| + private:
|
| + WorkerThreadTask(WorkerThread&, PassOwnPtr<ExecutionContextTask>, bool);
|
| +
|
| + WorkerThread& m_workerThread;
|
| + OwnPtr<ExecutionContextTask> m_task;
|
| + bool m_isInstrumented;
|
| + bool m_isIdleHandlerTask;
|
| + bool m_isTaskCanceled;
|
| + // Creation time stamp
|
| + double m_timeStamp;
|
| + };
|
| +
|
| public:
|
| virtual ~WorkerThread();
|
|
|
| @@ -98,6 +125,10 @@ public:
|
| void setWorkerInspectorController(WorkerInspectorController*);
|
|
|
| protected:
|
| + int decrementAndReturnTaskCount();
|
| + void queueUpIdleHandlerNow(long long delayMs);
|
| + int taskCount() { return m_tasksCount; }
|
| +
|
| WorkerThread(WorkerLoaderProxy&, WorkerReportingProxy&, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData>);
|
|
|
| // Factory method for creating a new worker context for the thread.
|
| @@ -116,6 +147,8 @@ private:
|
| void cleanup();
|
| void idleHandler();
|
| void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs);
|
| + // Method returns true if the task is canceled & cleared, else returns false
|
| + inline bool clearIdleHandlerTaskIfSet();
|
|
|
| bool m_terminated;
|
| OwnPtr<WorkerSharedTimer> m_sharedTimer;
|
| @@ -138,6 +171,9 @@ private:
|
| // Used to signal thread termination.
|
| OwnPtr<WebWaitableEvent> m_terminationEvent;
|
|
|
| + WorkerThreadTask* m_lastQueuedIdleHandlerTask;
|
| + volatile int m_tasksCount;
|
| +
|
| // FIXME: This has to be last because of crbug.com/401397 - the
|
| // WorkerThread might get deleted before it had a chance to properly
|
| // shut down. By deleting the WebThread first, we can guarantee that
|
|
|