Chromium Code Reviews| 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..04d32eabddb249f8835a9c271f9a5950c5a80f48 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); |
|
haraken
2016/03/03 12:08:46
Line 210 - 213 should be moved to V8Initializer::s
|
| shutdownWithoutV8(); |
| @@ -222,8 +217,20 @@ void shutdown() |
| void shutdownWithoutV8() |
|
yhirano
2016/03/03 18:03:11
I would like to guarantee that all non-main thread
haraken
2016/03/03 23:47:37
No, that is the key part of this CL. For example,
yhirano
2016/03/03 23:58:17
modulesInitializer().init() creates a HTMLParserTh
|
| { |
| + 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(); |