| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "core/fetch/WebCacheMemoryDumpProvider.h" | 41 #include "core/fetch/WebCacheMemoryDumpProvider.h" |
| 42 #include "core/frame/Settings.h" | 42 #include "core/frame/Settings.h" |
| 43 #include "core/page/Page.h" | 43 #include "core/page/Page.h" |
| 44 #include "core/workers/WorkerGlobalScopeProxy.h" | 44 #include "core/workers/WorkerGlobalScopeProxy.h" |
| 45 #include "gin/public/v8_platform.h" | 45 #include "gin/public/v8_platform.h" |
| 46 #include "modules/InitModules.h" | 46 #include "modules/InitModules.h" |
| 47 #include "platform/LayoutTestSupport.h" | 47 #include "platform/LayoutTestSupport.h" |
| 48 #include "platform/Logging.h" | 48 #include "platform/Logging.h" |
| 49 #include "platform/RuntimeEnabledFeatures.h" | 49 #include "platform/RuntimeEnabledFeatures.h" |
| 50 #include "platform/graphics/ImageDecodingStore.h" | 50 #include "platform/graphics/ImageDecodingStore.h" |
| 51 #include "platform/heap/GCTaskRunner.h" |
| 51 #include "platform/heap/Heap.h" | 52 #include "platform/heap/Heap.h" |
| 52 #include "platform/heap/MessageLoopInterruptor.h" | |
| 53 #include "platform/heap/PendingGCRunner.h" | |
| 54 #include "public/platform/Platform.h" | 53 #include "public/platform/Platform.h" |
| 55 #include "public/platform/WebPrerenderingSupport.h" | 54 #include "public/platform/WebPrerenderingSupport.h" |
| 56 #include "public/platform/WebThread.h" | 55 #include "public/platform/WebThread.h" |
| 57 #include "web/IndexedDBClientImpl.h" | 56 #include "web/IndexedDBClientImpl.h" |
| 58 #include "wtf/Assertions.h" | 57 #include "wtf/Assertions.h" |
| 59 #include "wtf/CryptographicallyRandomNumber.h" | 58 #include "wtf/CryptographicallyRandomNumber.h" |
| 60 #include "wtf/MainThread.h" | 59 #include "wtf/MainThread.h" |
| 61 #include "wtf/Partitions.h" | 60 #include "wtf/Partitions.h" |
| 62 #include "wtf/WTF.h" | 61 #include "wtf/WTF.h" |
| 63 #include "wtf/text/AtomicString.h" | 62 #include "wtf/text/AtomicString.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 93 { | 92 { |
| 94 m_function(m_context); | 93 m_function(m_context); |
| 95 } | 94 } |
| 96 private: | 95 private: |
| 97 WTF::MainThreadFunction* m_function; | 96 WTF::MainThreadFunction* m_function; |
| 98 void* m_context; | 97 void* m_context; |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 } // namespace | 100 } // namespace |
| 102 | 101 |
| 103 static WebThread::TaskObserver* s_endOfTaskRunner = 0; | 102 static WebThread::TaskObserver* s_endOfTaskRunner = nullptr; |
| 104 static WebThread::TaskObserver* s_pendingGCRunner = 0; | 103 static GCTaskRunner* s_gcTaskRunner = nullptr; |
| 105 | 104 |
| 106 // Make sure we are not re-initialized in the same address space. | 105 // Make sure we are not re-initialized in the same address space. |
| 107 // Doing so may cause hard to reproduce crashes. | 106 // Doing so may cause hard to reproduce crashes. |
| 108 static bool s_webKitInitialized = false; | 107 static bool s_webKitInitialized = false; |
| 109 | 108 |
| 110 void initialize(Platform* platform) | 109 void initialize(Platform* platform) |
| 111 { | 110 { |
| 112 initializeWithoutV8(platform); | 111 initializeWithoutV8(platform); |
| 113 | 112 |
| 114 V8Initializer::initializeMainThreadIfNeeded(); | 113 V8Initializer::initializeMainThreadIfNeeded(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 Platform::initialize(platform); | 176 Platform::initialize(platform); |
| 178 | 177 |
| 179 WTF::setRandomSource(cryptographicallyRandomValues); | 178 WTF::setRandomSource(cryptographicallyRandomValues); |
| 180 WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction, sy
stemTraceTimeFunction, histogramEnumerationFunction, adjustAmountOfExternalAlloc
atedMemory); | 179 WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction, sy
stemTraceTimeFunction, histogramEnumerationFunction, adjustAmountOfExternalAlloc
atedMemory); |
| 181 WTF::initializeMainThread(callOnMainThreadFunction); | 180 WTF::initializeMainThread(callOnMainThreadFunction); |
| 182 Heap::init(); | 181 Heap::init(); |
| 183 | 182 |
| 184 ThreadState::attachMainThread(); | 183 ThreadState::attachMainThread(); |
| 185 // currentThread() is null if we are running on a thread without a message l
oop. | 184 // currentThread() is null if we are running on a thread without a message l
oop. |
| 186 if (WebThread* currentThread = platform->currentThread()) { | 185 if (WebThread* currentThread = platform->currentThread()) { |
| 187 ASSERT(!s_pendingGCRunner); | 186 ASSERT(!s_gcTaskRunner); |
| 188 s_pendingGCRunner = new PendingGCRunner; | 187 s_gcTaskRunner = new GCTaskRunner(currentThread); |
| 189 currentThread->addTaskObserver(s_pendingGCRunner); | |
| 190 | |
| 191 OwnPtr<MessageLoopInterruptor> interruptor = adoptPtr(new MessageLoopInt
erruptor(currentThread->taskRunner())); | |
| 192 ThreadState::current()->addInterruptor(interruptor.release()); | |
| 193 } | 188 } |
| 194 | 189 |
| 195 DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ()); | 190 DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ()); |
| 196 initializer.init(); | 191 initializer.init(); |
| 197 | 192 |
| 198 setIndexedDBClientCreateFunction(IndexedDBClientImpl::create); | 193 setIndexedDBClientCreateFunction(IndexedDBClientImpl::create); |
| 199 } | 194 } |
| 200 | 195 |
| 201 void shutdown() | 196 void shutdown() |
| 202 { | 197 { |
| 203 // currentThread() is null if we are running on a thread without a message l
oop. | 198 // currentThread() is null if we are running on a thread without a message l
oop. |
| 204 if (Platform::current()->currentThread()) { | 199 if (Platform::current()->currentThread()) { |
| 205 Platform::current()->unregisterMemoryDumpProvider(WebCacheMemoryDumpProv
ider::instance()); | 200 Platform::current()->unregisterMemoryDumpProvider(WebCacheMemoryDumpProv
ider::instance()); |
| 206 | 201 |
| 207 // We don't need to (cannot) remove s_endOfTaskRunner from the current | 202 // We don't need to (cannot) remove s_endOfTaskRunner from the current |
| 208 // message loop, because the message loop is already destructed before | 203 // message loop, because the message loop is already destructed before |
| 209 // the shutdown() is called. | 204 // the shutdown() is called. |
| 210 delete s_endOfTaskRunner; | 205 delete s_endOfTaskRunner; |
| 211 s_endOfTaskRunner = 0; | 206 s_endOfTaskRunner = nullptr; |
| 212 | 207 |
| 213 ASSERT(s_pendingGCRunner); | 208 ASSERT(s_gcTaskRunner); |
| 214 delete s_pendingGCRunner; | 209 delete s_gcTaskRunner; |
| 215 s_pendingGCRunner = 0; | 210 s_gcTaskRunner = nullptr; |
| 216 } | 211 } |
| 217 | 212 |
| 218 // Shutdown V8-related background threads before V8 is ramped down. Note | 213 // Shutdown V8-related background threads before V8 is ramped down. Note |
| 219 // that this will wait the thread to stop its operations. | 214 // that this will wait the thread to stop its operations. |
| 220 ScriptStreamerThread::shutdown(); | 215 ScriptStreamerThread::shutdown(); |
| 221 | 216 |
| 222 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); | 217 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| 223 V8PerIsolateData::willBeDestroyed(isolate); | 218 V8PerIsolateData::willBeDestroyed(isolate); |
| 224 | 219 |
| 225 // Make sure we stop WorkerThreads before the main thread's ThreadState | 220 // Make sure we stop WorkerThreads before the main thread's ThreadState |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 ASSERT(!reloadPages); | 295 ASSERT(!reloadPages); |
| 301 Page::refreshPlugins(); | 296 Page::refreshPlugins(); |
| 302 } | 297 } |
| 303 | 298 |
| 304 void decommitFreeableMemory() | 299 void decommitFreeableMemory() |
| 305 { | 300 { |
| 306 WTF::Partitions::decommitFreeableMemory(); | 301 WTF::Partitions::decommitFreeableMemory(); |
| 307 } | 302 } |
| 308 | 303 |
| 309 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |