 Chromium Code Reviews
 Chromium Code Reviews Issue 507873003:
  [Blink-Worker] WorkerThread fires idleHandler only at the end of processing all tasks.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 507873003:
  [Blink-Worker] WorkerThread fires idleHandler only at the end of processing all tasks.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/core/workers/WorkerThread.h | 
| diff --git a/Source/core/workers/WorkerThread.h b/Source/core/workers/WorkerThread.h | 
| index 57b8ff8a4c97ff0867c135f8cebbc8e99d773d62..8a2695f0a9fb79236a4b389a7bb1f9fc301254b0 100644 | 
| --- a/Source/core/workers/WorkerThread.h | 
| +++ b/Source/core/workers/WorkerThread.h | 
| @@ -35,6 +35,7 @@ | 
| #include "platform/weborigin/SecurityOrigin.h" | 
| #include "wtf/Forward.h" | 
| #include "wtf/MessageQueue.h" | 
| +#include "wtf/Noncopyable.h" | 
| #include "wtf/OwnPtr.h" | 
| #include "wtf/PassRefPtr.h" | 
| #include "wtf/RefCounted.h" | 
| @@ -59,6 +60,29 @@ namespace blink { | 
| class WorkerThread : public RefCounted<WorkerThread> { | 
| + | 
| + class WorkerThreadTask : public blink::WebThread::Task { | 
| 
jochen (gone - plz use gerrit)
2014/10/14 13:46:03
nit. move down to the provide section.
it's also
 | 
| + 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; } | 
| + | 
| + private: | 
| + WorkerThreadTask(WorkerThread& | 
| + , PassOwnPtr<ExecutionContextTask>, bool); | 
| + | 
| + WorkerThread& m_workerThread; | 
| + OwnPtr<ExecutionContextTask> m_task; | 
| + bool m_isInstrumented; | 
| + bool m_isIdleHandlerTask; | 
| + }; | 
| + | 
| public: | 
| virtual ~WorkerThread(); | 
| @@ -99,6 +123,10 @@ namespace blink { | 
| 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. | 
| @@ -139,6 +167,9 @@ namespace blink { | 
| // Used to signal thread termination. | 
| OwnPtr<blink::WebWaitableEvent> m_terminationEvent; | 
| + bool m_IdleHandlerTaskPosted; | 
| + 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 |