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

Unified Diff: third_party/WebKit/Source/web/WebKit.cpp

Issue 1761853002: Shut down all threads before the main thread shuts down (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebKit.cpp
diff --git a/third_party/WebKit/Source/web/WebKit.cpp b/third_party/WebKit/Source/web/WebKit.cpp
index 4a4e0acd9a6215966422c5a75f13314917489b4a..0b34d329fe1731ff74d23c781dd3704634a42e34 100644
--- a/third_party/WebKit/Source/web/WebKit.cpp
+++ b/third_party/WebKit/Source/web/WebKit.cpp
@@ -141,6 +141,12 @@ static void adjustAmountOfExternalAllocatedMemory(int size)
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size);
}
+static ModulesInitializer& modulesInitializer()
+{
+ DEFINE_STATIC_LOCAL(OwnPtr<ModulesInitializer>, initializer, (adoptPtr(new ModulesInitializer)));
+ return *initializer;
+}
+
void initializeWithoutV8(Platform* platform)
{
ASSERT(!s_webKitInitialized);
@@ -161,8 +167,7 @@ void initializeWithoutV8(Platform* platform)
s_gcTaskRunner = new GCTaskRunner(currentThread);
}
- DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ());
- initializer.init();
+ modulesInitializer().init();
setIndexedDBClientCreateFunction(IndexedDBClientImpl::create);
}
@@ -194,27 +199,17 @@ void shutdown()
// the shutdown() is called.
delete s_endOfTaskRunner;
s_endOfTaskRunner = nullptr;
-
- ASSERT(s_gcTaskRunner);
- delete s_gcTaskRunner;
- s_gcTaskRunner = nullptr;
}
// Shutdown V8-related background threads before V8 is ramped down. Note
// that this will wait the thread to stop its operations.
ScriptStreamerThread::shutdown();
+ ThreadState::current()->unregisterTraceDOMWrappers();
+
v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate();
V8PerIsolateData::willBeDestroyed(isolate);
- CoreInitializer::terminateThreads();
-
- ModulesInitializer::terminateThreads();
-
- // Detach the main thread before starting the shutdown sequence
- // so that the main thread won't get involved in a GC during the shutdown.
- ThreadState::detachMainThread();
-
V8PerIsolateData::destroy(isolate);
shutdownWithoutV8();
@@ -222,8 +217,21 @@ void shutdown()
void shutdownWithoutV8()
{
+ ASSERT(isMainThread());
+ modulesInitializer().shutdown();
+
+ // currentThread() is null if we are running on a thread without a message loop.
+ if (Platform::current()->currentThread()) {
+ ASSERT(s_gcTaskRunner);
+ delete s_gcTaskRunner;
+ s_gcTaskRunner = nullptr;
+ }
+
+ // Detach the main thread before starting the shutdown sequence
+ // so that the main thread won't get involved in a GC during the shutdown.
+ ThreadState::detachMainThread();
+
ASSERT(!s_endOfTaskRunner);
- CoreInitializer::shutdown();
Heap::shutdown();
WTF::shutdown();
Platform::shutdown();
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698