Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: Source/core/workers/WorkerThread.h

Issue 956333002: Refactor TimeBase to post tasks. Workers to use real Idle tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Now uses the WebThread's WebScheduler Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 #include "wtf/PassRefPtr.h" 40 #include "wtf/PassRefPtr.h"
41 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
42 #include <v8.h> 42 #include <v8.h>
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 WorkerReportingProxy; 49 class WorkerReportingProxy;
50 class WorkerSharedTimer;
51 class WorkerThreadShutdownFinishTask; 50 class WorkerThreadShutdownFinishTask;
52 class WorkerThreadStartupData; 51 class WorkerThreadStartupData;
53 class WorkerThreadTask; 52 class WorkerThreadTask;
54 53
55 enum WorkerThreadStartMode { 54 enum WorkerThreadStartMode {
56 DontPauseWorkerGlobalScopeOnStart, 55 DontPauseWorkerGlobalScopeOnStart,
57 PauseWorkerGlobalScopeOnStart 56 PauseWorkerGlobalScopeOnStart
58 }; 57 };
59 58
60 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> { 59 class CORE_EXPORT WorkerThread : public RefCounted<WorkerThread> {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Factory method for creating a new worker context for the thread. 114 // Factory method for creating a new worker context for the thread.
116 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtr<WorkerThreadStartupData>) = 0; 115 virtual PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(Pa ssOwnPtr<WorkerThreadStartupData>) = 0;
117 116
118 virtual void postInitialize() { } 117 virtual void postInitialize() { }
119 118
120 virtual v8::Isolate* initializeIsolate(); 119 virtual v8::Isolate* initializeIsolate();
121 virtual void willDestroyIsolate(); 120 virtual void willDestroyIsolate();
122 virtual void destroyIsolate(); 121 virtual void destroyIsolate();
123 virtual void terminateV8Execution(); 122 virtual void terminateV8Execution();
124 123
124 // This is protected virtual for testing.
125 virtual bool doIdleGc(double deadlineSeconds);
126
127 WebThreadSupportingGC* threadForTesting() const
128 {
129 return m_thread.get();
130 }
131
125 private: 132 private:
126 friend class WorkerSharedTimer; 133 friend class WorkerThreadIdleTask;
127 friend class WorkerThreadShutdownFinishTask; 134 friend class WorkerThreadShutdownFinishTask;
128 135
129 void stopInShutdownSequence(); 136 void stopInShutdownSequence();
130 void stopInternal(); 137 void stopInternal();
131 138
132 void initialize(); 139 void initialize();
133 void cleanup(); 140 void cleanup();
134 void idleHandler(); 141 void idleTask(double deadlineSeconds);
135 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs); 142 void postDelayedTask(PassOwnPtr<ExecutionContextTask>, long long delayMs);
136 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas k>, long long delayMs); 143 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTas k>, long long delayMs);
137 144
138 const char* m_threadName; 145 const char* m_threadName;
139 bool m_terminated; 146 bool m_terminated;
140 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue; 147 MessageQueue<WorkerThreadTask> m_debuggerMessageQueue;
141 OwnPtr<WebThread::TaskObserver> m_microtaskRunner; 148 OwnPtr<WebThread::TaskObserver> m_microtaskRunner;
142 149
143 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; 150 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy;
144 WorkerReportingProxy& m_workerReportingProxy; 151 WorkerReportingProxy& m_workerReportingProxy;
145 152
146 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r; 153 RefPtrWillBePersistent<WorkerInspectorController> m_workerInspectorControlle r;
147 Mutex m_workerInspectorControllerMutex; 154 Mutex m_workerInspectorControllerMutex;
148 155
149 Mutex m_threadCreationMutex; 156 Mutex m_threadCreationMutex;
150 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; 157 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope;
151 OwnPtr<WorkerThreadStartupData> m_startupData; 158 OwnPtr<WorkerThreadStartupData> m_startupData;
152 159
153 v8::Isolate* m_isolate; 160 v8::Isolate* m_isolate;
154 OwnPtr<V8IsolateInterruptor> m_interruptor; 161 OwnPtr<V8IsolateInterruptor> m_interruptor;
155 162
156 // Used to signal thread shutdown. 163 // Used to signal thread shutdown.
157 OwnPtr<WebWaitableEvent> m_shutdownEvent; 164 OwnPtr<WebWaitableEvent> m_shutdownEvent;
158 165
159 // Used to signal thread termination. 166 // Used to signal thread termination.
160 OwnPtr<WebWaitableEvent> m_terminationEvent; 167 OwnPtr<WebWaitableEvent> m_terminationEvent;
161 168
169 WebScheduler* m_webScheduler; // NOT OWNED.
170
162 // FIXME: This has to be last because of crbug.com/401397 - the 171 // FIXME: This has to be last because of crbug.com/401397 - the
163 // WorkerThread might get deleted before it had a chance to properly 172 // WorkerThread might get deleted before it had a chance to properly
164 // shut down. By deleting the WebThread first, we can guarantee that 173 // shut down. By deleting the WebThread first, we can guarantee that
165 // no pending tasks on the thread might want to access any of the other 174 // no pending tasks on the thread might want to access any of the other
166 // members during the WorkerThread's destruction. 175 // members during the WorkerThread's destruction.
167 OwnPtr<WebThreadSupportingGC> m_thread; 176 OwnPtr<WebThreadSupportingGC> m_thread;
168 }; 177 };
169 178
170 } // namespace blink 179 } // namespace blink
171 180
172 #endif // WorkerThread_h 181 #endif // WorkerThread_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698