Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef WorkerThread_h | 27 #ifndef WorkerThread_h |
| 28 #define WorkerThread_h | 28 #define WorkerThread_h |
| 29 | 29 |
| 30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 31 #include "core/dom/ExecutionContextTask.h" | 31 #include "core/dom/ExecutionContextTask.h" |
| 32 #include "core/frame/csp/ContentSecurityPolicy.h" | 32 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 33 #include "core/workers/WorkerGlobalScope.h" | 33 #include "core/workers/WorkerGlobalScope.h" |
| 34 #include "core/workers/WorkerLoaderProxy.h" | 34 #include "core/workers/WorkerLoaderProxy.h" |
| 35 #include "core/workers/WorkerV8Isolate.h" | |
| 35 #include "platform/WebThreadSupportingGC.h" | 36 #include "platform/WebThreadSupportingGC.h" |
| 36 #include "platform/weborigin/SecurityOrigin.h" | 37 #include "platform/weborigin/SecurityOrigin.h" |
| 37 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 38 #include "wtf/MessageQueue.h" | 39 #include "wtf/MessageQueue.h" |
| 39 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 40 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
| 41 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
| 42 #include <v8.h> | 43 #include <v8.h> |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 65 virtual void stop(); | 66 virtual void stop(); |
| 66 | 67 |
| 67 // Returns the thread this worker runs on. Some implementations can create | 68 // Returns the thread this worker runs on. Some implementations can create |
| 68 // a new thread on the first call (e.g. shared, dedicated workers), whereas | 69 // a new thread on the first call (e.g. shared, dedicated workers), whereas |
| 69 // some implementations can use an existing thread that is already being | 70 // some implementations can use an existing thread that is already being |
| 70 // used by other workers (e.g. compositor workers). | 71 // used by other workers (e.g. compositor workers). |
| 71 virtual WebThreadSupportingGC& backingThread() = 0; | 72 virtual WebThreadSupportingGC& backingThread() = 0; |
| 72 | 73 |
| 73 virtual void didStartRunLoop(); | 74 virtual void didStartRunLoop(); |
| 74 virtual void didStopRunLoop(); | 75 virtual void didStopRunLoop(); |
| 76 virtual void initializeBackingThread(); | |
| 77 virtual void shutdownBackingThread(); | |
|
kinuko
2015/05/28 16:21:59
Are they called outside WorkerThread or subclass?
sadrul
2015/05/28 16:51:56
These are called only from inside WorkerThread, ex
| |
| 75 | 78 |
| 76 v8::Isolate* isolate() const { return m_isolate; } | 79 v8::Isolate* isolate() const { return m_isolate ? m_isolate->isolate() : nul lptr; } |
| 77 | 80 |
| 78 // Can be used to wait for this worker thread to shut down. | 81 // Can be used to wait for this worker thread to shut down. |
| 79 // (This is signalled on the main thread, so it's assumed to be waited on th e worker context thread) | 82 // (This is signalled on the main thread, so it's assumed to be waited on th e worker context thread) |
| 80 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } | 83 WebWaitableEvent* shutdownEvent() { return m_shutdownEvent.get(); } |
| 81 | 84 |
| 82 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); } | 85 WebWaitableEvent* terminationEvent() { return m_terminationEvent.get(); } |
| 83 void terminateAndWait(); | 86 void terminateAndWait(); |
| 84 static void terminateAndWaitForAllWorkers(); | 87 static void terminateAndWaitForAllWorkers(); |
| 85 | 88 |
| 86 bool isCurrentThread(); | 89 bool isCurrentThread(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 115 void setWorkerInspectorController(WorkerInspectorController*); | 118 void setWorkerInspectorController(WorkerInspectorController*); |
| 116 | 119 |
| 117 protected: | 120 protected: |
| 118 WorkerThread(PassRefPtr<WorkerLoaderProxy>, WorkerReportingProxy&); | 121 WorkerThread(PassRefPtr<WorkerLoaderProxy>, WorkerReportingProxy&); |
| 119 | 122 |
| 120 // Factory method for creating a new worker context for the thread. | 123 // Factory method for creating a new worker context for the thread. |
| 121 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtr<WorkerThreadStartupData>) = 0; | 124 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtr<WorkerThreadStartupData>) = 0; |
| 122 | 125 |
| 123 virtual void postInitialize() { } | 126 virtual void postInitialize() { } |
| 124 | 127 |
| 125 virtual v8::Isolate* initializeIsolate(); | 128 virtual PassOwnPtr<WorkerV8Isolate> initializeIsolate(); |
| 126 virtual void willDestroyIsolate(); | 129 virtual void willDestroyIsolate(); |
| 127 virtual void destroyIsolate(); | 130 virtual void destroyIsolate(); |
| 128 virtual void terminateV8Execution(); | 131 virtual void terminateV8Execution(); |
| 129 | 132 |
| 130 // This is protected virtual for testing. | 133 // This is protected virtual for testing. |
| 131 virtual bool doIdleGc(double deadlineSeconds); | 134 virtual bool doIdleGc(double deadlineSeconds); |
| 132 | 135 |
| 133 private: | 136 private: |
| 134 friend class WorkerSharedTimer; | 137 friend class WorkerSharedTimer; |
| 135 friend class WorkerMicrotaskRunner; | 138 friend class WorkerMicrotaskRunner; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 148 MessageQueue<WebThread::Task> m_debuggerMessageQueue; | 151 MessageQueue<WebThread::Task> m_debuggerMessageQueue; |
| 149 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; | 152 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; |
| 150 | 153 |
| 151 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; | 154 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; |
| 152 WorkerReportingProxy& m_workerReportingProxy; | 155 WorkerReportingProxy& m_workerReportingProxy; |
| 153 RawPtr<WebScheduler> m_webScheduler; // Not owned. | 156 RawPtr<WebScheduler> m_webScheduler; // Not owned. |
| 154 | 157 |
| 155 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r; | 158 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r; |
| 156 Mutex m_workerInspectorControllerMutex; | 159 Mutex m_workerInspectorControllerMutex; |
| 157 | 160 |
| 158 // This lock protects |m_workerGlobalScope|, |m_terminated|, |m_isolate| and |m_microtaskRunner|. | 161 // This lock protects |m_workerGlobalScope|, |m_terminated|, and |m_isolate| . |
| 159 Mutex m_threadStateMutex; | 162 Mutex m_threadStateMutex; |
| 160 | 163 |
| 161 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 164 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |
| 162 | 165 |
| 163 v8::Isolate* m_isolate; | 166 OwnPtr<WorkerV8Isolate> m_isolate; |
|
kinuko
2015/05/28 16:21:59
thread and isolate are used in a very similar way,
sadrul
2015/05/28 16:51:56
They don't actually have to be. It needs a little
sadrul
2015/05/28 18:00:47
I have gone ahead and made this change. PTAL.
kinuko
2015/05/29 17:45:18
Well, was just asking because I vaguely remember y
sadrul
2015/05/29 18:26:32
I was, yes! (I was going to put it in WebThreadSup
kinuko
2015/05/31 15:18:24
WebThreadSupportingGC is used not only for JS-cont
| |
| 164 OwnPtr<V8IsolateInterruptor> m_interruptor; | |
| 165 | 167 |
| 166 // Used to signal thread shutdown. | 168 // Used to signal thread shutdown. |
| 167 OwnPtr<WebWaitableEvent> m_shutdownEvent; | 169 OwnPtr<WebWaitableEvent> m_shutdownEvent; |
| 168 | 170 |
| 169 // Used to signal thread termination. | 171 // Used to signal thread termination. |
| 170 OwnPtr<WebWaitableEvent> m_terminationEvent; | 172 OwnPtr<WebWaitableEvent> m_terminationEvent; |
| 171 }; | 173 }; |
| 172 | 174 |
| 173 } // namespace blink | 175 } // namespace blink |
| 174 | 176 |
| 175 #endif // WorkerThread_h | 177 #endif // WorkerThread_h |
| OLD | NEW |