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

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

Issue 203393002: Revert of Explicit notification and removal of lifecycle observers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/platform/LifecycleNotifier.h » ('j') | 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get()); 128 m_workerReportingProxy.workerGlobalScopeStarted(m_workerGlobalScope.get());
129 129
130 WorkerScriptController* script = m_workerGlobalScope->script(); 130 WorkerScriptController* script = m_workerGlobalScope->script();
131 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode); 131 InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), star tMode);
132 script->evaluate(ScriptSourceCode(sourceCode, scriptURL)); 132 script->evaluate(ScriptSourceCode(sourceCode, scriptURL));
133 133
134 runEventLoop(); 134 runEventLoop();
135 135
136 ThreadIdentifier threadID = m_threadID; 136 ThreadIdentifier threadID = m_threadID;
137 137
138 #if !ENABLE(OILPAN) 138 // The below assignment will destroy the context, which will in turn notify messaging proxy.
139 // We cannot let any objects survive past thread exit, because no other thre ad will run GC or otherwise destroy them.
140 // If Oilpan is enabled, we detach of the context/global scope, with the fin al heap cleanup below sweeping it out.
141 #if ENABLE(OILPAN)
142 m_workerGlobalScope->dispose();
143 #else
139 ASSERT(m_workerGlobalScope->hasOneRef()); 144 ASSERT(m_workerGlobalScope->hasOneRef());
140 #endif 145 #endif
141 // Dispose of the WorkerGlobalScope and its context. If Oilpan is not enable d, clearing
142 // m_workerGlobalScope synchronously destructs the object. If Oilpan is enab led,
143 // that finalization will instead happen when a final GC is run below during
144 // ThreadState::detach().
145 m_workerGlobalScope->dispose();
146 m_workerGlobalScope = nullptr; 146 m_workerGlobalScope = nullptr;
147 147
148 // Notify the proxy that the WorkerGlobalScope has been disposed of. 148 ThreadState::detach();
149 // This can free this thread object, hence it must not be touched afterwards .
150 workerReportingProxy().workerGlobalScopeDestroyed();
151 149
152 // Clean up PlatformThreadData before WTF::WTFThreadData goes away! 150 // Clean up PlatformThreadData before WTF::WTFThreadData goes away!
153 PlatformThreadData::current().destroy(); 151 PlatformThreadData::current().destroy();
154 152
155 // The thread object may be already destroyed from notification now, don't t ry to access "this". 153 // The thread object may be already destroyed from notification now, don't t ry to access "this".
156 detachThread(threadID); 154 detachThread(threadID);
157
158 // And, finally, detach the ThreadState, cleaning out the thread's
159 // heap by performing a final GC. The cleanup operation will at
160 // the end assert that the heap is empty, as any surviving objects
161 // will otherwise leak and never be destructed.
162 ThreadState::detach();
163 } 155 }
164 156
165 void WorkerThread::runEventLoop() 157 void WorkerThread::runEventLoop()
166 { 158 {
167 // Does not return until terminated. 159 // Does not return until terminated.
168 m_runLoop.run(); 160 m_runLoop.run();
169 } 161 }
170 162
171 class WorkerThreadShutdownFinishTask : public ExecutionContextTask { 163 class WorkerThreadShutdownFinishTask : public ExecutionContextTask {
172 public: 164 public:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() 237 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads()
246 { 238 {
247 MutexLocker lock(threadSetMutex()); 239 MutexLocker lock(threadSetMutex());
248 HashSet<WorkerThread*>& threads = workerThreads(); 240 HashSet<WorkerThread*>& threads = workerThreads();
249 HashSet<WorkerThread*>::iterator end = threads.end(); 241 HashSet<WorkerThread*>::iterator end = threads.end();
250 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it) 242 for (HashSet<WorkerThread*>::iterator it = threads.begin(); it != end; ++it)
251 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ; 243 (*it)->runLoop().postTask(adoptPtr(new ReleaseFastMallocFreeMemoryTask)) ;
252 } 244 }
253 245
254 } // namespace WebCore 246 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/platform/LifecycleNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698