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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 PauseWorkerGlobalScopeOnStart | 57 PauseWorkerGlobalScopeOnStart |
58 }; | 58 }; |
59 | 59 |
60 class WorkerThread : public RefCounted<WorkerThread> { | 60 class WorkerThread : public RefCounted<WorkerThread> { |
61 public: | 61 public: |
62 virtual ~WorkerThread(); | 62 virtual ~WorkerThread(); |
63 | 63 |
64 virtual void start(); | 64 virtual void start(); |
65 virtual void stop(); | 65 virtual void stop(); |
66 | 66 |
67 void didStartRunLoop(); | 67 virtual PassOwnPtr<WebThreadSupportingGC> createWebThreadSupportingGC(); |
68 void didStopRunLoop(); | 68 virtual void didStartRunLoop(); |
| 69 virtual void didStopRunLoop(); |
69 | 70 |
70 v8::Isolate* isolate() const { return m_isolate; } | 71 v8::Isolate* isolate() const { return m_isolate; } |
71 | 72 |
72 // Can be used to wait for this worker thread to shut down. | 73 // Can be used to wait for this worker thread to shut down. |
73 // (This is signalled on the main thread, so it's assumed to be waited on th
e worker context thread) | 74 // (This is signalled on the main thread, so it's assumed to be waited on th
e worker context thread) |
74 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } | 75 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } |
75 | 76 |
76 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); } | 77 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); } |
77 void terminateAndWait(); | 78 void terminateAndWait(); |
78 static void terminateAndWaitForAllWorkers(); | 79 static void terminateAndWaitForAllWorkers(); |
(...skipping 30 matching lines...) Expand all Loading... |
109 void setWorkerInspectorController(WorkerInspectorController*); | 110 void setWorkerInspectorController(WorkerInspectorController*); |
110 | 111 |
111 protected: | 112 protected: |
112 WorkerThread(PassRefPtr<WorkerLoaderProxy>, WorkerReportingProxy&, PassOwnPt
rWillBeRawPtr<WorkerThreadStartupData>); | 113 WorkerThread(PassRefPtr<WorkerLoaderProxy>, WorkerReportingProxy&, PassOwnPt
rWillBeRawPtr<WorkerThreadStartupData>); |
113 | 114 |
114 // Factory method for creating a new worker context for the thread. | 115 // Factory method for creating a new worker context for the thread. |
115 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa
ssOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; | 116 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa
ssOwnPtrWillBeRawPtr<WorkerThreadStartupData>) = 0; |
116 | 117 |
117 virtual void postInitialize() { } | 118 virtual void postInitialize() { } |
118 | 119 |
| 120 virtual v8::Isolate* initializeIsolate(); |
| 121 virtual void willDestroyIsolate(); |
| 122 virtual void destroyIsolate(); |
| 123 virtual void terminateV8Execution(); |
| 124 |
119 private: | 125 private: |
120 friend class WorkerSharedTimer; | 126 friend class WorkerSharedTimer; |
121 friend class WorkerThreadShutdownFinishTask; | 127 friend class WorkerThreadShutdownFinishTask; |
122 | 128 |
123 void stopInShutdownSequence(); | 129 void stopInShutdownSequence(); |
124 void stopInternal(); | 130 void stopInternal(); |
125 | 131 |
126 void initialize(); | 132 void initialize(); |
127 void cleanup(); | 133 void cleanup(); |
128 void idleHandler(); | 134 void idleHandler(); |
129 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs); | 135 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs); |
130 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas
k>, long long delayMs); | 136 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas
k>, long long delayMs); |
131 | 137 |
132 v8::Isolate* initializeIsolate(); | |
133 void willDestroyIsolate(); | |
134 void destroyIsolate(); | |
135 void terminateV8Execution(); | |
136 | |
137 bool m_terminated; | 138 bool m_terminated; |
138 OwnPtr<WorkerSharedTimer> m_sharedTimer; | 139 OwnPtr<WorkerSharedTimer> m_sharedTimer; |
139 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; | 140 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; |
140 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; | 141 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; |
141 | 142 |
142 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; | 143 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; |
143 WorkerReportingProxy& m_workerReportingProxy; | 144 WorkerReportingProxy& m_workerReportingProxy; |
144 | 145 |
145 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle
r; | 146 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle
r; |
146 Mutex m_workerInspectorControllerMutex; | 147 Mutex m_workerInspectorControllerMutex; |
(...skipping 15 matching lines...) Expand all Loading... |
162 // WorkerThread might get deleted before it had a chance to properly | 163 // WorkerThread might get deleted before it had a chance to properly |
163 // shut down. By deleting the WebThread first, we can guarantee that | 164 // shut down. By deleting the WebThread first, we can guarantee that |
164 // no pending tasks on the thread might want to access any of the other | 165 // no pending tasks on the thread might want to access any of the other |
165 // members during the WorkerThread's destruction. | 166 // members during the WorkerThread's destruction. |
166 OwnPtr<WebThreadSupportingGC> m_thread; | 167 OwnPtr<WebThreadSupportingGC> m_thread; |
167 }; | 168 }; |
168 | 169 |
169 } // namespace blink | 170 } // namespace blink |
170 | 171 |
171 #endif // WorkerThread_h | 172 #endif // WorkerThread_h |
OLD | NEW |