OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 class WorkerMicrotaskRunner : public WebThread::TaskObserver { | 61 class WorkerMicrotaskRunner : public WebThread::TaskObserver { |
62 public: | 62 public: |
63 explicit WorkerMicrotaskRunner(WorkerThread* workerThread) | 63 explicit WorkerMicrotaskRunner(WorkerThread* workerThread) |
64 : m_workerThread(workerThread) | 64 : m_workerThread(workerThread) |
65 { | 65 { |
66 } | 66 } |
67 | 67 |
68 virtual void willProcessTask() override | 68 void willProcessTask() override |
69 { | 69 { |
70 // No tasks should get executed after we have closed. | 70 // No tasks should get executed after we have closed. |
71 WorkerGlobalScope* globalScope = m_workerThread->workerGlobalScope(); | 71 WorkerGlobalScope* globalScope = m_workerThread->workerGlobalScope(); |
72 ASSERT_UNUSED(globalScope, !globalScope || !globalScope->isClosing()); | 72 ASSERT_UNUSED(globalScope, !globalScope || !globalScope->isClosing()); |
73 } | 73 } |
74 | 74 |
75 virtual void didProcessTask() override | 75 void didProcessTask() override |
76 { | 76 { |
77 Microtask::performCheckpoint(m_workerThread->isolate()); | 77 Microtask::performCheckpoint(m_workerThread->isolate()); |
78 if (WorkerGlobalScope* globalScope = m_workerThread->workerGlobalScope()
) { | 78 if (WorkerGlobalScope* globalScope = m_workerThread->workerGlobalScope()
) { |
79 if (WorkerScriptController* scriptController = globalScope->script()
) | 79 if (WorkerScriptController* scriptController = globalScope->script()
) |
80 scriptController->rejectedPromises()->processQueue(); | 80 scriptController->rejectedPromises()->processQueue(); |
81 if (globalScope->isClosing()) { | 81 if (globalScope->isClosing()) { |
82 m_workerThread->workerReportingProxy().workerGlobalScopeClosed()
; | 82 m_workerThread->workerReportingProxy().workerGlobalScopeClosed()
; |
83 m_workerThread->shutdown(); | 83 m_workerThread->shutdown(); |
84 } | 84 } |
85 } | 85 } |
(...skipping 24 matching lines...) Expand all Loading... |
110 } | 110 } |
111 | 111 |
112 class WorkerThreadTask : public WebThread::Task { | 112 class WorkerThreadTask : public WebThread::Task { |
113 WTF_MAKE_NONCOPYABLE(WorkerThreadTask); WTF_MAKE_FAST_ALLOCATED(WorkerThread
Task); | 113 WTF_MAKE_NONCOPYABLE(WorkerThreadTask); WTF_MAKE_FAST_ALLOCATED(WorkerThread
Task); |
114 public: | 114 public: |
115 static PassOwnPtr<WorkerThreadTask> create(WorkerThread& workerThread, PassO
wnPtr<ExecutionContextTask> task, bool isInstrumented) | 115 static PassOwnPtr<WorkerThreadTask> create(WorkerThread& workerThread, PassO
wnPtr<ExecutionContextTask> task, bool isInstrumented) |
116 { | 116 { |
117 return adoptPtr(new WorkerThreadTask(workerThread, task, isInstrumented)
); | 117 return adoptPtr(new WorkerThreadTask(workerThread, task, isInstrumented)
); |
118 } | 118 } |
119 | 119 |
120 virtual ~WorkerThreadTask() { } | 120 ~WorkerThreadTask() override { } |
121 | 121 |
122 virtual void run() override | 122 void run() override |
123 { | 123 { |
124 WorkerGlobalScope* workerGlobalScope = m_workerThread.workerGlobalScope(
); | 124 WorkerGlobalScope* workerGlobalScope = m_workerThread.workerGlobalScope(
); |
125 // If the thread is terminated before it had a chance initialize (see | 125 // If the thread is terminated before it had a chance initialize (see |
126 // WorkerThread::Initialize()), we mustn't run any of the posted tasks. | 126 // WorkerThread::Initialize()), we mustn't run any of the posted tasks. |
127 if (!workerGlobalScope) { | 127 if (!workerGlobalScope) { |
128 ASSERT(m_workerThread.terminated()); | 128 ASSERT(m_workerThread.terminated()); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 if (m_isInstrumented) | 132 if (m_isInstrumented) |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); | 489 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); |
490 } | 490 } |
491 | 491 |
492 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
rInspectorController) | 492 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke
rInspectorController) |
493 { | 493 { |
494 MutexLocker locker(m_workerInspectorControllerMutex); | 494 MutexLocker locker(m_workerInspectorControllerMutex); |
495 m_workerInspectorController = workerInspectorController; | 495 m_workerInspectorController = workerInspectorController; |
496 } | 496 } |
497 | 497 |
498 } // namespace blink | 498 } // namespace blink |
OLD | NEW |