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 20 matching lines...) Expand all Loading... | |
31 #include "bindings/core/v8/ScriptSourceCode.h" | 31 #include "bindings/core/v8/ScriptSourceCode.h" |
32 #include "bindings/core/v8/V8GCController.h" | 32 #include "bindings/core/v8/V8GCController.h" |
33 #include "bindings/core/v8/V8Initializer.h" | 33 #include "bindings/core/v8/V8Initializer.h" |
34 #include "core/dom/Microtask.h" | 34 #include "core/dom/Microtask.h" |
35 #include "core/inspector/InspectorInstrumentation.h" | 35 #include "core/inspector/InspectorInstrumentation.h" |
36 #include "core/inspector/WorkerInspectorController.h" | 36 #include "core/inspector/WorkerInspectorController.h" |
37 #include "core/workers/DedicatedWorkerGlobalScope.h" | 37 #include "core/workers/DedicatedWorkerGlobalScope.h" |
38 #include "core/workers/WorkerClients.h" | 38 #include "core/workers/WorkerClients.h" |
39 #include "core/workers/WorkerReportingProxy.h" | 39 #include "core/workers/WorkerReportingProxy.h" |
40 #include "core/workers/WorkerThreadStartupData.h" | 40 #include "core/workers/WorkerThreadStartupData.h" |
41 #include "platform/PlatformThreadData.h" | |
42 #include "platform/Task.h" | 41 #include "platform/Task.h" |
43 #include "platform/ThreadTimers.h" | |
44 #include "platform/heap/SafePoint.h" | 42 #include "platform/heap/SafePoint.h" |
45 #include "platform/heap/ThreadState.h" | 43 #include "platform/heap/ThreadState.h" |
46 #include "platform/weborigin/KURL.h" | 44 #include "platform/weborigin/KURL.h" |
47 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
46 #include "public/platform/WebScheduler.h" | |
48 #include "public/platform/WebThread.h" | 47 #include "public/platform/WebThread.h" |
49 #include "public/platform/WebWaitableEvent.h" | 48 #include "public/platform/WebWaitableEvent.h" |
50 #include "wtf/Noncopyable.h" | 49 #include "wtf/Noncopyable.h" |
51 #include "wtf/WeakPtr.h" | 50 #include "wtf/WeakPtr.h" |
52 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
53 | 52 |
54 namespace blink { | 53 namespace blink { |
55 | 54 |
56 namespace { | 55 namespace { |
57 const int64_t kShortIdleHandlerDelayMs = 1000; | |
58 const int64_t kLongIdleHandlerDelayMs = 10*1000; | |
59 | 56 |
60 class MicrotaskRunner : public WebThread::TaskObserver { | 57 class MicrotaskRunner : public WebThread::TaskObserver { |
61 public: | 58 public: |
62 explicit MicrotaskRunner(WorkerThread* workerThread) | 59 explicit MicrotaskRunner(WorkerThread* workerThread) |
63 : m_workerThread(workerThread) | 60 : m_workerThread(workerThread) |
64 { | 61 { |
65 } | 62 } |
66 | 63 |
67 virtual void willProcessTask() override { } | 64 virtual void willProcessTask() override { } |
68 virtual void didProcessTask() override | 65 virtual void didProcessTask() override |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 : m_closure(closure) | 121 : m_closure(closure) |
125 , m_weakFactory(this) | 122 , m_weakFactory(this) |
126 , m_taskCanceled(false) | 123 , m_taskCanceled(false) |
127 { } | 124 { } |
128 | 125 |
129 OwnPtr<Closure> m_closure; | 126 OwnPtr<Closure> m_closure; |
130 WeakPtrFactory<WorkerThreadCancelableTask> m_weakFactory; | 127 WeakPtrFactory<WorkerThreadCancelableTask> m_weakFactory; |
131 bool m_taskCanceled; | 128 bool m_taskCanceled; |
132 }; | 129 }; |
133 | 130 |
134 class WorkerSharedTimer : public SharedTimer { | |
135 public: | |
136 explicit WorkerSharedTimer(WorkerThread* workerThread) | |
137 : m_workerThread(workerThread) | |
138 , m_running(false) | |
139 { } | |
140 | |
141 typedef void (*SharedTimerFunction)(); | |
142 virtual void setFiredFunction(SharedTimerFunction func) | |
143 { | |
144 m_sharedTimerFunction = func; | |
145 } | |
146 | |
147 virtual void setFireInterval(double interval) | |
148 { | |
149 ASSERT(m_sharedTimerFunction); | |
150 | |
151 // See BlinkPlatformImpl::setSharedTimerFireInterval for explanation of | |
152 // why ceil is used in the interval calculation. | |
153 int64_t delay = static_cast<int64_t>(ceil(interval * 1000)); | |
154 | |
155 if (delay < 0) { | |
156 delay = 0; | |
157 } | |
158 | |
159 m_running = true; | |
160 | |
161 if (m_lastQueuedTask.get()) | |
162 m_lastQueuedTask->cancelTask(); | |
163 | |
164 // Now queue the task as a cancellable one. | |
165 OwnPtr<WorkerThreadCancelableTask> task = WorkerThreadCancelableTask::cr eate(bind(&WorkerSharedTimer::OnTimeout, this)); | |
166 m_lastQueuedTask = task->createWeakPtr(); | |
167 m_workerThread->postDelayedTask(FROM_HERE, task.release(), delay); | |
168 } | |
169 | |
170 virtual void stop() | |
171 { | |
172 m_running = false; | |
173 m_lastQueuedTask = nullptr; | |
174 } | |
175 | |
176 private: | |
177 void OnTimeout() | |
178 { | |
179 ASSERT(m_workerThread->workerGlobalScope()); | |
180 | |
181 m_lastQueuedTask = nullptr; | |
182 | |
183 if (m_sharedTimerFunction && m_running && !m_workerThread->workerGlobalS cope()->isClosing()) | |
184 m_sharedTimerFunction(); | |
185 } | |
186 | |
187 WorkerThread* m_workerThread; | |
188 SharedTimerFunction m_sharedTimerFunction; | |
189 bool m_running; | |
190 | |
191 // The task to run OnTimeout, if any. While OnTimeout resets | |
192 // m_lastQueuedTask, this must be a weak pointer because the | |
193 // worker runloop may delete the task as it is shutting down. | |
194 WeakPtr<WorkerThreadCancelableTask> m_lastQueuedTask; | |
195 }; | |
196 | |
197 class WorkerThreadTask : public blink::WebThread::Task { | 131 class WorkerThreadTask : public blink::WebThread::Task { |
198 WTF_MAKE_NONCOPYABLE(WorkerThreadTask); WTF_MAKE_FAST_ALLOCATED(WorkerThread Task); | 132 WTF_MAKE_NONCOPYABLE(WorkerThreadTask); WTF_MAKE_FAST_ALLOCATED(WorkerThread Task); |
199 public: | 133 public: |
200 static PassOwnPtr<WorkerThreadTask> create(WorkerThread& workerThread, PassO wnPtr<ExecutionContextTask> task, bool isInstrumented) | 134 static PassOwnPtr<WorkerThreadTask> create(WorkerThread& workerThread, PassO wnPtr<ExecutionContextTask> task, bool isInstrumented) |
201 { | 135 { |
202 return adoptPtr(new WorkerThreadTask(workerThread, task, isInstrumented) ); | 136 return adoptPtr(new WorkerThreadTask(workerThread, task, isInstrumented) ); |
203 } | 137 } |
204 | 138 |
205 virtual ~WorkerThreadTask() { } | 139 virtual ~WorkerThreadTask() { } |
206 | 140 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 | 191 |
258 WorkerThread::WorkerThread(const char* threadName, PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, PassOwnPtr<Worke rThreadStartupData> startupData) | 192 WorkerThread::WorkerThread(const char* threadName, PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, PassOwnPtr<Worke rThreadStartupData> startupData) |
259 : m_threadName(threadName) | 193 : m_threadName(threadName) |
260 , m_terminated(false) | 194 , m_terminated(false) |
261 , m_workerLoaderProxy(workerLoaderProxy) | 195 , m_workerLoaderProxy(workerLoaderProxy) |
262 , m_workerReportingProxy(workerReportingProxy) | 196 , m_workerReportingProxy(workerReportingProxy) |
263 , m_startupData(startupData) | 197 , m_startupData(startupData) |
264 , m_isolate(nullptr) | 198 , m_isolate(nullptr) |
265 , m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent() )) | 199 , m_shutdownEvent(adoptPtr(blink::Platform::current()->createWaitableEvent() )) |
266 , m_terminationEvent(adoptPtr(blink::Platform::current()->createWaitableEven t())) | 200 , m_terminationEvent(adoptPtr(blink::Platform::current()->createWaitableEven t())) |
201 , m_webScheduler(nullptr) | |
267 { | 202 { |
268 MutexLocker lock(threadSetMutex()); | 203 MutexLocker lock(threadSetMutex()); |
269 workerThreads().add(this); | 204 workerThreads().add(this); |
270 } | 205 } |
271 | 206 |
272 WorkerThread::~WorkerThread() | 207 WorkerThread::~WorkerThread() |
273 { | 208 { |
274 MutexLocker lock(threadSetMutex()); | 209 MutexLocker lock(threadSetMutex()); |
275 ASSERT(workerThreads().contains(this)); | 210 ASSERT(workerThreads().contains(this)); |
276 workerThreads().remove(this); | 211 workerThreads().remove(this); |
(...skipping 15 matching lines...) Expand all Loading... | |
292 m_workerInspectorController->interruptAndDispatchInspectorCommands(); | 227 m_workerInspectorController->interruptAndDispatchInspectorCommands(); |
293 } | 228 } |
294 | 229 |
295 PlatformThreadId WorkerThread::platformThreadId() const | 230 PlatformThreadId WorkerThread::platformThreadId() const |
296 { | 231 { |
297 if (!m_thread) | 232 if (!m_thread) |
298 return 0; | 233 return 0; |
299 return m_thread->platformThread().threadId(); | 234 return m_thread->platformThread().threadId(); |
300 } | 235 } |
301 | 236 |
237 class WorkerThreadIdleTask : public WebThread::IdleTask { | |
238 public: | |
239 explicit WorkerThreadIdleTask(WorkerThread* thread) | |
240 : m_thread(thread) { } | |
241 | |
242 ~WorkerThreadIdleTask() override { } | |
243 | |
244 void run(double deadlineSeconds) override | |
245 { | |
246 m_thread->idleTask(deadlineSeconds); | |
247 } | |
248 | |
249 private: | |
250 RawPtr<WorkerThread> m_thread; | |
251 }; | |
252 | |
302 void WorkerThread::initialize() | 253 void WorkerThread::initialize() |
303 { | 254 { |
304 KURL scriptURL = m_startupData->m_scriptURL; | 255 KURL scriptURL = m_startupData->m_scriptURL; |
305 String sourceCode = m_startupData->m_sourceCode; | 256 String sourceCode = m_startupData->m_sourceCode; |
306 WorkerThreadStartMode startMode = m_startupData->m_startMode; | 257 WorkerThreadStartMode startMode = m_startupData->m_startMode; |
307 OwnPtr<Vector<char>> cachedMetaData = m_startupData->m_cachedMetaData.releas e(); | 258 OwnPtr<Vector<char>> cachedMetaData = m_startupData->m_cachedMetaData.releas e(); |
308 V8CacheOptions v8CacheOptions = m_startupData->m_v8CacheOptions; | 259 V8CacheOptions v8CacheOptions = m_startupData->m_v8CacheOptions; |
309 | 260 |
310 { | 261 { |
311 MutexLocker lock(m_threadCreationMutex); | 262 MutexLocker lock(m_threadCreationMutex); |
312 | 263 |
313 // The worker was terminated before the thread had a chance to run. | 264 // The worker was terminated before the thread had a chance to run. |
314 if (m_terminated) { | 265 if (m_terminated) { |
315 // Notify the proxy that the WorkerGlobalScope has been disposed of. | 266 // Notify the proxy that the WorkerGlobalScope has been disposed of. |
316 // This can free this thread object, hence it must not be touched af terwards. | 267 // This can free this thread object, hence it must not be touched af terwards. |
317 m_workerReportingProxy.workerThreadTerminated(); | 268 m_workerReportingProxy.workerThreadTerminated(); |
318 return; | 269 return; |
319 } | 270 } |
320 | 271 |
321 m_microtaskRunner = adoptPtr(new MicrotaskRunner(this)); | 272 m_microtaskRunner = adoptPtr(new MicrotaskRunner(this)); |
322 m_thread->addTaskObserver(m_microtaskRunner.get()); | 273 m_thread->addTaskObserver(m_microtaskRunner.get()); |
323 m_thread->attachGC(); | 274 m_thread->attachGC(); |
324 | 275 |
325 m_isolate = initializeIsolate(); | 276 m_isolate = initializeIsolate(); |
326 m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release()); | 277 m_workerGlobalScope = createWorkerGlobalScope(m_startupData.release()); |
327 m_workerGlobalScope->scriptLoaded(sourceCode.length(), cachedMetaData.ge t() ? cachedMetaData->size() : 0); | 278 m_workerGlobalScope->scriptLoaded(sourceCode.length(), cachedMetaData.ge t() ? cachedMetaData->size() : 0); |
328 | |
329 PlatformThreadData::current().threadTimers().setSharedTimer(adoptPtr(new WorkerSharedTimer(this))); | |
330 } | 279 } |
331 | 280 |
332 // The corresponding call to stopRunLoop() is in ~WorkerScriptController(). | 281 // The corresponding call to stopRunLoop() is in ~WorkerScriptController(). |
333 didStartRunLoop(); | 282 didStartRunLoop(); |
334 | 283 |
335 // Notify proxy that a new WorkerGlobalScope has been created and started. | 284 // Notify proxy that a new WorkerGlobalScope has been created and started. |
336 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); | 285 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); |
337 | 286 |
338 WorkerScriptController* script = m_workerGlobalScope->script(); | 287 WorkerScriptController* script = m_workerGlobalScope->script(); |
339 if (!script->isExecutionForbidden()) | 288 if (!script->isExecutionForbidden()) |
340 script->initializeContextIfNeeded(); | 289 script->initializeContextIfNeeded(); |
341 if (startMode == PauseWorkerGlobalScopeOnStart) | 290 if (startMode == PauseWorkerGlobalScopeOnStart) |
342 m_workerGlobalScope->workerInspectorController()->pauseOnStart(); | 291 m_workerGlobalScope->workerInspectorController()->pauseOnStart(); |
343 | 292 |
344 OwnPtr<CachedMetadataHandler> handler(workerGlobalScope()->createWorkerScrip tCachedMetadataHandler(scriptURL, cachedMetaData.get())); | 293 OwnPtr<CachedMetadataHandler> handler(workerGlobalScope()->createWorkerScrip tCachedMetadataHandler(scriptURL, cachedMetaData.get())); |
345 bool success = script->evaluate(ScriptSourceCode(sourceCode, scriptURL), nul lptr, handler.get(), v8CacheOptions); | 294 bool success = script->evaluate(ScriptSourceCode(sourceCode, scriptURL), nul lptr, handler.get(), v8CacheOptions); |
346 m_workerGlobalScope->didEvaluateWorkerScript(); | 295 m_workerGlobalScope->didEvaluateWorkerScript(); |
347 m_workerReportingProxy.didEvaluateWorkerScript(success); | 296 m_workerReportingProxy.didEvaluateWorkerScript(success); |
348 | 297 |
349 postInitialize(); | 298 postInitialize(); |
350 | 299 |
351 postDelayedTask(FROM_HERE, createSameThreadTask(&WorkerThread::idleHandler, this), kShortIdleHandlerDelayMs); | 300 m_webScheduler = m_thread->platformThread().scheduler(); |
301 m_webScheduler->postIdleTaskAfterWakeup(FROM_HERE, new WorkerThreadIdleTask( this)); | |
rmcilroy
2015/04/17 12:59:33
Can we just use WTF::Bind here to avoid having to
alex clarke (OOO till 29th)
2015/04/17 13:37:08
I wish I could but the type ereasure of WTF::bind
rmcilroy
2015/04/17 16:33:22
Ahh sad. In that case this is fine.
| |
352 } | 302 } |
353 | 303 |
354 PassOwnPtr<WebThreadSupportingGC> WorkerThread::createWebThreadSupportingGC() | 304 PassOwnPtr<WebThreadSupportingGC> WorkerThread::createWebThreadSupportingGC() |
355 { | 305 { |
356 return WebThreadSupportingGC::create(m_threadName); | 306 return WebThreadSupportingGC::create(m_threadName); |
357 } | 307 } |
358 | 308 |
359 void WorkerThread::cleanup() | 309 void WorkerThread::cleanup() |
360 { | 310 { |
361 // This should be called before we start the shutdown procedure. | 311 // This should be called before we start the shutdown procedure. |
(...skipping 12 matching lines...) Expand all Loading... | |
374 destroyIsolate(); | 324 destroyIsolate(); |
375 | 325 |
376 m_thread->removeTaskObserver(m_microtaskRunner.get()); | 326 m_thread->removeTaskObserver(m_microtaskRunner.get()); |
377 m_microtaskRunner = nullptr; | 327 m_microtaskRunner = nullptr; |
378 | 328 |
379 // Notify the proxy that the WorkerGlobalScope has been disposed of. | 329 // Notify the proxy that the WorkerGlobalScope has been disposed of. |
380 // This can free this thread object, hence it must not be touched afterwards . | 330 // This can free this thread object, hence it must not be touched afterwards . |
381 workerReportingProxy().workerThreadTerminated(); | 331 workerReportingProxy().workerThreadTerminated(); |
382 | 332 |
383 m_terminationEvent->signal(); | 333 m_terminationEvent->signal(); |
384 | |
385 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! | |
386 PlatformThreadData::current().destroy(); | |
387 } | 334 } |
388 | 335 |
389 class WorkerThreadShutdownFinishTask : public ExecutionContextTask { | 336 class WorkerThreadShutdownFinishTask : public ExecutionContextTask { |
390 public: | 337 public: |
391 static PassOwnPtr<WorkerThreadShutdownFinishTask> create() | 338 static PassOwnPtr<WorkerThreadShutdownFinishTask> create() |
392 { | 339 { |
393 return adoptPtr(new WorkerThreadShutdownFinishTask()); | 340 return adoptPtr(new WorkerThreadShutdownFinishTask()); |
394 } | 341 } |
395 | 342 |
396 virtual void performTask(ExecutionContext *context) | 343 virtual void performTask(ExecutionContext *context) |
(...skipping 13 matching lines...) Expand all Loading... | |
410 public: | 357 public: |
411 static PassOwnPtr<WorkerThreadShutdownStartTask> create() | 358 static PassOwnPtr<WorkerThreadShutdownStartTask> create() |
412 { | 359 { |
413 return adoptPtr(new WorkerThreadShutdownStartTask()); | 360 return adoptPtr(new WorkerThreadShutdownStartTask()); |
414 } | 361 } |
415 | 362 |
416 virtual void performTask(ExecutionContext *context) | 363 virtual void performTask(ExecutionContext *context) |
417 { | 364 { |
418 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 365 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
419 workerGlobalScope->stopActiveDOMObjects(); | 366 workerGlobalScope->stopActiveDOMObjects(); |
420 PlatformThreadData::current().threadTimers().setSharedTimer(nullptr); | |
421 | 367 |
422 // Event listeners would keep DOMWrapperWorld objects alive for too long . Also, they have references to JS objects, | 368 // Event listeners would keep DOMWrapperWorld objects alive for too long . Also, they have references to JS objects, |
423 // which become dangling once Heap is destroyed. | 369 // which become dangling once Heap is destroyed. |
424 workerGlobalScope->removeAllEventListeners(); | 370 workerGlobalScope->removeAllEventListeners(); |
425 | 371 |
426 // Stick a shutdown command at the end of the queue, so that we deal | 372 // Stick a shutdown command at the end of the queue, so that we deal |
427 // with all the cleanup tasks the databases post first. | 373 // with all the cleanup tasks the databases post first. |
428 workerGlobalScope->postTask(FROM_HERE, WorkerThreadShutdownFinishTask::c reate()); | 374 workerGlobalScope->postTask(FROM_HERE, WorkerThreadShutdownFinishTask::c reate()); |
429 } | 375 } |
430 | 376 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 | 448 |
503 for (WorkerThread* thread : threads) | 449 for (WorkerThread* thread : threads) |
504 thread->terminationEvent()->wait(); | 450 thread->terminationEvent()->wait(); |
505 } | 451 } |
506 | 452 |
507 bool WorkerThread::isCurrentThread() const | 453 bool WorkerThread::isCurrentThread() const |
508 { | 454 { |
509 return m_thread && m_thread->isCurrentThread(); | 455 return m_thread && m_thread->isCurrentThread(); |
510 } | 456 } |
511 | 457 |
512 void WorkerThread::idleHandler() | 458 void WorkerThread::idleTask(double deadlineSeconds) |
513 { | 459 { |
514 ASSERT(m_workerGlobalScope.get()); | 460 double gcDeadlineSeconds = deadlineSeconds; |
515 int64_t delay = kLongIdleHandlerDelayMs; | |
516 | 461 |
517 // Do a script engine idle notification if the next event is distant enough. | 462 // The V8 GC does some GC steps (e.g. compaction) only when the idle notific ation is ~1s. |
518 const double kMinIdleTimespan = 0.3; | 463 // TODO(rmcilroy): Refactor so extending the deadline like this this isn't n eeded. |
519 const double nextFireTime = PlatformThreadData::current().threadTimers().nex tFireTime(); | 464 if (m_webScheduler->canExceedIdleDeadlineIfRequired()) |
520 if (nextFireTime == 0.0 || nextFireTime > currentTime() + kMinIdleTimespan) { | 465 gcDeadlineSeconds = Platform::current()->monotonicallyIncreasingTime() + 1.0; |
rmcilroy
2015/04/17 12:59:33
add back the kLongIdleHandlerDelay as a constant a
alex clarke (OOO till 29th)
2015/04/17 13:37:08
Done.
| |
521 bool hasMoreWork = !isolate()->IdleNotificationDeadline(Platform::curren t()->monotonicallyIncreasingTime() + 1.0); | 466 |
522 if (hasMoreWork) | 467 if (doIdleGc(gcDeadlineSeconds)) |
rmcilroy
2015/04/17 12:59:33
nit - I would prefer this function is inlined - i.
alex clarke (OOO till 29th)
2015/04/17 13:37:08
I split the doIdleGc function off so I could test
rmcilroy
2015/04/17 16:33:22
I missed you were using this in testing. In that c
alex clarke (OOO till 29th)
2015/04/20 10:06:53
OK although I may get asked to change it back sinc
rmcilroy
2015/04/20 20:56:49
Thanks!
| |
523 delay = kShortIdleHandlerDelayMs; | 468 m_webScheduler->postIdleTaskAfterWakeup(FROM_HERE, new WorkerThreadIdleT ask(this)); |
469 else | |
470 m_webScheduler->postIdleTask(FROM_HERE, new WorkerThreadIdleTask(this)); | |
471 } | |
472 | |
473 bool WorkerThread::doIdleGc(double deadlineSeconds) | |
474 { | |
475 if (deadlineSeconds > Platform::current()->monotonicallyIncreasingTime()) { | |
476 return isolate()->IdleNotificationDeadline(deadlineSeconds); | |
524 } | 477 } |
525 | 478 |
526 postDelayedTask(FROM_HERE, createSameThreadTask(&WorkerThread::idleHandler, this), delay); | 479 return false; |
527 } | 480 } |
528 | 481 |
529 void WorkerThread::postTask(const WebTraceLocation& location, PassOwnPtr<Executi onContextTask> task) | 482 void WorkerThread::postTask(const WebTraceLocation& location, PassOwnPtr<Executi onContextTask> task) |
530 { | 483 { |
531 m_thread->postTask(location, WorkerThreadTask::create(*this, task, true).lea kPtr()); | 484 m_thread->postTask(location, WorkerThreadTask::create(*this, task, true).lea kPtr()); |
532 } | 485 } |
533 | 486 |
534 void WorkerThread::postDelayedTask(const WebTraceLocation& location, PassOwnPtr< ExecutionContextTask> task, long long delayMs) | 487 void WorkerThread::postDelayedTask(const WebTraceLocation& location, PassOwnPtr< ExecutionContextTask> task, long long delayMs) |
535 { | 488 { |
536 m_thread->postDelayedTask(location, WorkerThreadTask::create(*this, task, tr ue).leakPtr(), delayMs); | 489 m_thread->postDelayedTask(location, WorkerThreadTask::create(*this, task, tr ue).leakPtr(), delayMs); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); | 563 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); |
611 } | 564 } |
612 | 565 |
613 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) | 566 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) |
614 { | 567 { |
615 MutexLocker locker(m_workerInspectorControllerMutex); | 568 MutexLocker locker(m_workerInspectorControllerMutex); |
616 m_workerInspectorController = workerInspectorController; | 569 m_workerInspectorController = workerInspectorController; |
617 } | 570 } |
618 | 571 |
619 } // namespace blink | 572 } // namespace blink |
OLD | NEW |