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

Side by Side Diff: third_party/WebKit/Source/core/workers/WorkerThread.cpp

Issue 2054703003: Worker: Remove unnecessary indirection on WorkerThread::postTask() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@avoid_debugger_task
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 return m_started && workerBackingThread().backingThread().isCurrentThread(); 218 return m_started && workerBackingThread().backingThread().isCurrentThread();
219 } 219 }
220 220
221 void WorkerThread::postTask(const WebTraceLocation& location, std::unique_ptr<Ex ecutionContextTask> task) 221 void WorkerThread::postTask(const WebTraceLocation& location, std::unique_ptr<Ex ecutionContextTask> task)
222 { 222 {
223 { 223 {
224 MutexLocker lock(m_threadStateMutex); 224 MutexLocker lock(m_threadStateMutex);
225 if (m_terminated || m_readyToShutdown) 225 if (m_terminated || m_readyToShutdown)
226 return; 226 return;
227 } 227 }
228 workerBackingThread().backingThread().postTask(location, createWorkerThreadT ask(std::move(task), true)); 228
229 bool isInstrumented = !task->taskNameForInstrumentation().isEmpty();
230 if (isInstrumented) {
231 DCHECK(isCurrentThread());
232 InspectorInstrumentation::asyncTaskScheduled(workerGlobalScope(), "Worke r task", task.get());
233 }
234 workerBackingThread().backingThread().postTask(location, threadSafeBind(&Wor kerThread::performTaskOnWorkerThread, AllowCrossThreadAccess(this), passed(std:: move(task)), isInstrumented));
229 } 235 }
230 236
231 void WorkerThread::appendDebuggerTask(std::unique_ptr<CrossThreadClosure> task) 237 void WorkerThread::appendDebuggerTask(std::unique_ptr<CrossThreadClosure> task)
232 { 238 {
233 DCHECK(isMainThread()); 239 DCHECK(isMainThread());
234 { 240 {
235 MutexLocker lock(m_threadStateMutex); 241 MutexLocker lock(m_threadStateMutex);
236 if (m_terminated) 242 if (m_terminated)
237 return; 243 return;
238 } 244 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 WaitableEvent::ResetPolicy::Manual, 309 WaitableEvent::ResetPolicy::Manual,
304 WaitableEvent::InitialState::NonSignaled))) 310 WaitableEvent::InitialState::NonSignaled)))
305 , m_shutdownEvent(adoptPtr(new WaitableEvent( 311 , m_shutdownEvent(adoptPtr(new WaitableEvent(
306 WaitableEvent::ResetPolicy::Manual, 312 WaitableEvent::ResetPolicy::Manual,
307 WaitableEvent::InitialState::NonSignaled))) 313 WaitableEvent::InitialState::NonSignaled)))
308 { 314 {
309 MutexLocker lock(threadSetMutex()); 315 MutexLocker lock(threadSetMutex());
310 workerThreads().add(this); 316 workerThreads().add(this);
311 } 317 }
312 318
313 std::unique_ptr<CrossThreadClosure> WorkerThread::createWorkerThreadTask(std::un ique_ptr<ExecutionContextTask> task, bool isInstrumented)
314 {
315 if (isInstrumented)
316 isInstrumented = !task->taskNameForInstrumentation().isEmpty();
317 if (isInstrumented) {
318 DCHECK(isCurrentThread());
319 InspectorInstrumentation::asyncTaskScheduled(workerGlobalScope(), "Worke r task", task.get());
320 }
321 return threadSafeBind(&WorkerThread::performTaskOnWorkerThread, AllowCrossTh readAccess(this), passed(std::move(task)), isInstrumented);
322 }
323
324 void WorkerThread::terminateInternal(TerminationMode mode) 319 void WorkerThread::terminateInternal(TerminationMode mode)
325 { 320 {
326 DCHECK(m_started); 321 DCHECK(m_started);
327 322
328 // Prevent the deadlock between GC and an attempt to terminate a thread. 323 // Prevent the deadlock between GC and an attempt to terminate a thread.
329 SafePointScope safePointScope(BlinkGC::HeapPointersOnStack); 324 SafePointScope safePointScope(BlinkGC::HeapPointersOnStack);
330 325
331 // Protect against this method, initializeOnWorkerThread() or termination 326 // Protect against this method, initializeOnWorkerThread() or termination
332 // via the global scope racing each other. 327 // via the global scope racing each other.
333 MutexLocker lock(m_threadStateMutex); 328 MutexLocker lock(m_threadStateMutex);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 (*task)(); 580 (*task)();
586 } 581 }
587 582
588 WorkerThread::ExitCode WorkerThread::getExitCode() 583 WorkerThread::ExitCode WorkerThread::getExitCode()
589 { 584 {
590 MutexLocker lock(m_threadStateMutex); 585 MutexLocker lock(m_threadStateMutex);
591 return m_exitCode; 586 return m_exitCode;
592 } 587 }
593 588
594 } // namespace blink 589 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698