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

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

Issue 2718643002: Worker: Pass ParentFrameTaskRunners via WorkerThread::start() instead of the ctor (Closed)
Patch Set: Created 3 years, 10 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 workerThreads().erase(this); 97 workerThreads().erase(this);
98 98
99 DCHECK_NE(ExitCode::NotTerminated, m_exitCode); 99 DCHECK_NE(ExitCode::NotTerminated, m_exitCode);
100 DEFINE_THREAD_SAFE_STATIC_LOCAL( 100 DEFINE_THREAD_SAFE_STATIC_LOCAL(
101 EnumerationHistogram, exitCodeHistogram, 101 EnumerationHistogram, exitCodeHistogram,
102 new EnumerationHistogram("WorkerThread.ExitCode", 102 new EnumerationHistogram("WorkerThread.ExitCode",
103 static_cast<int>(ExitCode::LastEnum))); 103 static_cast<int>(ExitCode::LastEnum)));
104 exitCodeHistogram.count(static_cast<int>(m_exitCode)); 104 exitCodeHistogram.count(static_cast<int>(m_exitCode));
105 } 105 }
106 106
107 void WorkerThread::start(std::unique_ptr<WorkerThreadStartupData> startupData) { 107 void WorkerThread::start(std::unique_ptr<WorkerThreadStartupData> startupData,
108 ParentFrameTaskRunners* parentFrameTaskRunners) {
108 DCHECK(isMainThread()); 109 DCHECK(isMainThread());
109 110
110 if (m_requestedToStart) 111 if (m_requestedToStart)
111 return; 112 return;
112 113
113 m_requestedToStart = true; 114 m_requestedToStart = true;
115 m_parentFrameTaskRunners = parentFrameTaskRunners;
114 workerBackingThread().backingThread().postTask( 116 workerBackingThread().backingThread().postTask(
115 BLINK_FROM_HERE, crossThreadBind(&WorkerThread::initializeOnWorkerThread, 117 BLINK_FROM_HERE, crossThreadBind(&WorkerThread::initializeOnWorkerThread,
116 crossThreadUnretained(this), 118 crossThreadUnretained(this),
117 WTF::passed(std::move(startupData)))); 119 WTF::passed(std::move(startupData))));
118 } 120 }
119 121
120 void WorkerThread::terminate() { 122 void WorkerThread::terminate() {
121 DCHECK(isMainThread()); 123 DCHECK(isMainThread());
122 terminateInternal(TerminationMode::Graceful); 124 terminateInternal(TerminationMode::Graceful);
123 } 125 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return true; 279 return true;
278 case ExitCode::LastEnum: 280 case ExitCode::LastEnum:
279 NOTREACHED() << static_cast<int>(m_exitCode); 281 NOTREACHED() << static_cast<int>(m_exitCode);
280 return false; 282 return false;
281 } 283 }
282 NOTREACHED() << static_cast<int>(m_exitCode); 284 NOTREACHED() << static_cast<int>(m_exitCode);
283 return false; 285 return false;
284 } 286 }
285 287
286 WorkerThread::WorkerThread(PassRefPtr<WorkerLoaderProxy> workerLoaderProxy, 288 WorkerThread::WorkerThread(PassRefPtr<WorkerLoaderProxy> workerLoaderProxy,
287 WorkerReportingProxy& workerReportingProxy, 289 WorkerReportingProxy& workerReportingProxy)
288 ParentFrameTaskRunners* parentFrameTaskRunners)
289 : m_workerThreadId(getNextWorkerThreadId()), 290 : m_workerThreadId(getNextWorkerThreadId()),
290 m_forcibleTerminationDelayInMs(kForcibleTerminationDelayInMs), 291 m_forcibleTerminationDelayInMs(kForcibleTerminationDelayInMs),
291 m_inspectorTaskRunner(WTF::makeUnique<InspectorTaskRunner>()), 292 m_inspectorTaskRunner(WTF::makeUnique<InspectorTaskRunner>()),
292 m_workerLoaderProxy(workerLoaderProxy), 293 m_workerLoaderProxy(workerLoaderProxy),
293 m_workerReportingProxy(workerReportingProxy), 294 m_workerReportingProxy(workerReportingProxy),
294 m_parentFrameTaskRunners(parentFrameTaskRunners),
295 m_shutdownEvent(WTF::wrapUnique( 295 m_shutdownEvent(WTF::wrapUnique(
296 new WaitableEvent(WaitableEvent::ResetPolicy::Manual, 296 new WaitableEvent(WaitableEvent::ResetPolicy::Manual,
297 WaitableEvent::InitialState::NonSignaled))), 297 WaitableEvent::InitialState::NonSignaled))),
298 m_workerThreadLifecycleContext(new WorkerThreadLifecycleContext) { 298 m_workerThreadLifecycleContext(new WorkerThreadLifecycleContext) {
299 DCHECK(isMainThread()); 299 DCHECK(isMainThread());
300 MutexLocker lock(threadSetMutex()); 300 MutexLocker lock(threadSetMutex());
301 workerThreads().insert(this); 301 workerThreads().insert(this);
302 } 302 }
303 303
304 void WorkerThread::terminateInternal(TerminationMode mode) { 304 void WorkerThread::terminateInternal(TerminationMode mode) {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 MutexLocker lock(m_threadStateMutex); 642 MutexLocker lock(m_threadStateMutex);
643 return m_requestedToTerminate; 643 return m_requestedToTerminate;
644 } 644 }
645 645
646 ExitCode WorkerThread::getExitCodeForTesting() { 646 ExitCode WorkerThread::getExitCodeForTesting() {
647 MutexLocker lock(m_threadStateMutex); 647 MutexLocker lock(m_threadStateMutex);
648 return m_exitCode; 648 return m_exitCode;
649 } 649 }
650 650
651 } // namespace blink 651 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.h ('k') | third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698