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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 class WebWaitableEvent; | 46 class WebWaitableEvent; |
47 class WorkerGlobalScope; | 47 class WorkerGlobalScope; |
48 class WorkerInspectorController; | 48 class WorkerInspectorController; |
49 class WorkerMicrotaskRunner; | 49 class WorkerMicrotaskRunner; |
50 class WorkerReportingProxy; | 50 class WorkerReportingProxy; |
51 class WorkerSharedTimer; | 51 class WorkerSharedTimer; |
52 class WorkerThreadStartupData; | 52 class WorkerThreadStartupData; |
53 class WorkerThreadTask; | |
54 | 53 |
55 enum WorkerThreadStartMode { | 54 enum WorkerThreadStartMode { |
56 DontPauseWorkerGlobalScopeOnStart, | 55 DontPauseWorkerGlobalScopeOnStart, |
57 PauseWorkerGlobalScopeOnStart | 56 PauseWorkerGlobalScopeOnStart |
58 }; | 57 }; |
59 | 58 |
60 // TODO(sadrul): Rename to WorkerScript. | 59 // TODO(sadrul): Rename to WorkerScript. |
61 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> { | 60 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> { |
62 public: | 61 public: |
63 virtual ~WorkerThread(); | 62 virtual ~WorkerThread(); |
(...skipping 23 matching lines...) Expand all Loading... |
87 bool isCurrentThread(); | 86 bool isCurrentThread(); |
88 WorkerLoaderProxy* workerLoaderProxy() const | 87 WorkerLoaderProxy* workerLoaderProxy() const |
89 { | 88 { |
90 RELEASE_ASSERT(m_workerLoaderProxy); | 89 RELEASE_ASSERT(m_workerLoaderProxy); |
91 return m_workerLoaderProxy.get(); | 90 return m_workerLoaderProxy.get(); |
92 } | 91 } |
93 | 92 |
94 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin
gProxy; } | 93 WorkerReportingProxy& workerReportingProxy() const { return m_workerReportin
gProxy; } |
95 | 94 |
96 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); | 95 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); |
97 void postDebuggerTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTa
sk>); | 96 void appendDebuggerTask(PassOwnPtr<WebThread::Task>); |
98 | 97 |
99 enum WaitMode { WaitForMessage, DontWaitForMessage }; | 98 enum WaitMode { WaitForMessage, DontWaitForMessage }; |
100 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage); | 99 MessageQueueWaitResult runDebuggerTask(WaitMode = WaitForMessage); |
101 | 100 |
102 // These methods should be called if the holder of the thread is | 101 // These methods should be called if the holder of the thread is |
103 // going to call runDebuggerTask in a loop. | 102 // going to call runDebuggerTask in a loop. |
104 void willEnterNestedLoop(); | 103 void willEnterNestedLoop(); |
105 void didLeaveNestedLoop(); | 104 void didLeaveNestedLoop(); |
106 | 105 |
107 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge
t(); } | 106 WorkerGlobalScope* workerGlobalScope() const { return m_workerGlobalScope.ge
t(); } |
(...skipping 26 matching lines...) Expand all Loading... |
134 private: | 133 private: |
135 friend class WorkerSharedTimer; | 134 friend class WorkerSharedTimer; |
136 friend class WorkerMicrotaskRunner; | 135 friend class WorkerMicrotaskRunner; |
137 | 136 |
138 void stopInShutdownSequence(); | 137 void stopInShutdownSequence(); |
139 void stopInternal(); | 138 void stopInternal(); |
140 | 139 |
141 void initialize(PassOwnPtr<WorkerThreadStartupData>); | 140 void initialize(PassOwnPtr<WorkerThreadStartupData>); |
142 void shutdown(); | 141 void shutdown(); |
143 void performIdleWork(double deadlineSeconds); | 142 void performIdleWork(double deadlineSeconds); |
144 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs); | |
145 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas
k>, long long delayMs); | 143 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas
k>, long long delayMs); |
146 | 144 |
147 bool m_started; | 145 bool m_started; |
148 bool m_terminated; | 146 bool m_terminated; |
149 bool m_shutdown; | 147 bool m_shutdown; |
150 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; | 148 MessageQueue<WebThread::Task> m_debuggerMessageQueue; |
151 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; | 149 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; |
152 | 150 |
153 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; | 151 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; |
154 WorkerReportingProxy& m_workerReportingProxy; | 152 WorkerReportingProxy& m_workerReportingProxy; |
155 RawPtr<WebScheduler> m_webScheduler; // Not owned. | 153 RawPtr<WebScheduler> m_webScheduler; // Not owned. |
156 | 154 |
157 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle
r; | 155 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle
r; |
158 Mutex m_workerInspectorControllerMutex; | 156 Mutex m_workerInspectorControllerMutex; |
159 | 157 |
160 // This lock protects |m_workerGlobalScope|, |m_terminated|, |m_isolate| and
|m_microtaskRunner|. | 158 // This lock protects |m_workerGlobalScope|, |m_terminated|, |m_isolate| and
|m_microtaskRunner|. |
161 Mutex m_threadStateMutex; | 159 Mutex m_threadStateMutex; |
162 | 160 |
163 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 161 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |
164 | 162 |
165 v8::Isolate* m_isolate; | 163 v8::Isolate* m_isolate; |
166 OwnPtr<V8IsolateInterruptor> m_interruptor; | 164 OwnPtr<V8IsolateInterruptor> m_interruptor; |
167 | 165 |
168 // Used to signal thread shutdown. | 166 // Used to signal thread shutdown. |
169 OwnPtr<WebWaitableEvent> m_shutdownEvent; | 167 OwnPtr<WebWaitableEvent> m_shutdownEvent; |
170 | 168 |
171 // Used to signal thread termination. | 169 // Used to signal thread termination. |
172 OwnPtr<WebWaitableEvent> m_terminationEvent; | 170 OwnPtr<WebWaitableEvent> m_terminationEvent; |
173 }; | 171 }; |
174 | 172 |
175 } // namespace blink | 173 } // namespace blink |
176 | 174 |
177 #endif // WorkerThread_h | 175 #endif // WorkerThread_h |
OLD | NEW |