| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 private: | 95 private: |
| 96 WTF::MainThreadFunction* m_function; | 96 WTF::MainThreadFunction* m_function; |
| 97 void* m_context; | 97 void* m_context; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace | 100 } // namespace |
| 101 | 101 |
| 102 static WebThread::TaskObserver* s_endOfTaskRunner = 0; | 102 static WebThread::TaskObserver* s_endOfTaskRunner = 0; |
| 103 static WebThread::TaskObserver* s_pendingGCRunner = 0; | 103 static WebThread::TaskObserver* s_pendingGCRunner = 0; |
| 104 static ThreadState::Interruptor* s_messageLoopInterruptor = 0; | |
| 105 static ThreadState::Interruptor* s_isolateInterruptor = 0; | |
| 106 | 104 |
| 107 // 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. |
| 108 // Doing so may cause hard to reproduce crashes. | 106 // Doing so may cause hard to reproduce crashes. |
| 109 static bool s_webKitInitialized = false; | 107 static bool s_webKitInitialized = false; |
| 110 | 108 |
| 111 void initialize(Platform* platform) | 109 void initialize(Platform* platform) |
| 112 { | 110 { |
| 113 initializeWithoutV8(platform); | 111 initializeWithoutV8(platform); |
| 114 | 112 |
| 115 V8Initializer::initializeMainThreadIfNeeded(); | 113 V8Initializer::initializeMainThreadIfNeeded(); |
| 116 | 114 |
| 117 s_isolateInterruptor = new V8IsolateInterruptor(V8PerIsolateData::mainThread
Isolate()); | 115 ThreadState::current()->addInterruptor(new V8IsolateInterruptor(V8PerIsolate
Data::mainThreadIsolate())); |
| 118 ThreadState::current()->addInterruptor(s_isolateInterruptor); | |
| 119 ThreadState::current()->registerTraceDOMWrappers(V8PerIsolateData::mainThrea
dIsolate(), V8GCController::traceDOMWrappers); | 116 ThreadState::current()->registerTraceDOMWrappers(V8PerIsolateData::mainThrea
dIsolate(), V8GCController::traceDOMWrappers); |
| 120 | 117 |
| 121 // currentThread is null if we are running on a thread without a message loo
p. | 118 // currentThread is null if we are running on a thread without a message loo
p. |
| 122 if (WebThread* currentThread = platform->currentThread()) { | 119 if (WebThread* currentThread = platform->currentThread()) { |
| 123 ASSERT(!s_endOfTaskRunner); | 120 ASSERT(!s_endOfTaskRunner); |
| 124 s_endOfTaskRunner = new EndOfTaskRunner; | 121 s_endOfTaskRunner = new EndOfTaskRunner; |
| 125 currentThread->addTaskObserver(s_endOfTaskRunner); | 122 currentThread->addTaskObserver(s_endOfTaskRunner); |
| 126 } | 123 } |
| 127 } | 124 } |
| 128 | 125 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 WTF::initializeMainThread(callOnMainThreadFunction); | 176 WTF::initializeMainThread(callOnMainThreadFunction); |
| 180 Heap::init(); | 177 Heap::init(); |
| 181 | 178 |
| 182 ThreadState::attachMainThread(); | 179 ThreadState::attachMainThread(); |
| 183 // currentThread() is null if we are running on a thread without a message l
oop. | 180 // currentThread() is null if we are running on a thread without a message l
oop. |
| 184 if (WebThread* currentThread = platform->currentThread()) { | 181 if (WebThread* currentThread = platform->currentThread()) { |
| 185 ASSERT(!s_pendingGCRunner); | 182 ASSERT(!s_pendingGCRunner); |
| 186 s_pendingGCRunner = new PendingGCRunner; | 183 s_pendingGCRunner = new PendingGCRunner; |
| 187 currentThread->addTaskObserver(s_pendingGCRunner); | 184 currentThread->addTaskObserver(s_pendingGCRunner); |
| 188 | 185 |
| 189 ASSERT(!s_messageLoopInterruptor); | 186 ThreadState::current()->addInterruptor(new MessageLoopInterruptor(curren
tThread)); |
| 190 s_messageLoopInterruptor = new MessageLoopInterruptor(currentThread); | |
| 191 ThreadState::current()->addInterruptor(s_messageLoopInterruptor); | |
| 192 } | 187 } |
| 193 | 188 |
| 194 DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ()); | 189 DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ()); |
| 195 initializer.init(); | 190 initializer.init(); |
| 196 | 191 |
| 197 setIndexedDBClientCreateFunction(IndexedDBClientImpl::create); | 192 setIndexedDBClientCreateFunction(IndexedDBClientImpl::create); |
| 198 } | 193 } |
| 199 | 194 |
| 200 void shutdown() | 195 void shutdown() |
| 201 { | 196 { |
| 202 // currentThread() is null if we are running on a thread without a message l
oop. | 197 // currentThread() is null if we are running on a thread without a message l
oop. |
| 203 if (Platform::current()->currentThread()) { | 198 if (Platform::current()->currentThread()) { |
| 204 // We don't need to (cannot) remove s_endOfTaskRunner from the current | 199 // We don't need to (cannot) remove s_endOfTaskRunner from the current |
| 205 // message loop, because the message loop is already destructed before | 200 // message loop, because the message loop is already destructed before |
| 206 // the shutdown() is called. | 201 // the shutdown() is called. |
| 207 delete s_endOfTaskRunner; | 202 delete s_endOfTaskRunner; |
| 208 s_endOfTaskRunner = 0; | 203 s_endOfTaskRunner = 0; |
| 209 } | 204 } |
| 210 | 205 |
| 211 ASSERT(s_isolateInterruptor); | |
| 212 ThreadState::current()->removeInterruptor(s_isolateInterruptor); | |
| 213 | |
| 214 // currentThread() is null if we are running on a thread without a message l
oop. | 206 // currentThread() is null if we are running on a thread without a message l
oop. |
| 215 if (Platform::current()->currentThread()) { | 207 if (Platform::current()->currentThread()) { |
| 216 ASSERT(s_pendingGCRunner); | 208 ASSERT(s_pendingGCRunner); |
| 217 delete s_pendingGCRunner; | 209 delete s_pendingGCRunner; |
| 218 s_pendingGCRunner = 0; | 210 s_pendingGCRunner = 0; |
| 219 | |
| 220 ASSERT(s_messageLoopInterruptor); | |
| 221 ThreadState::current()->removeInterruptor(s_messageLoopInterruptor); | |
| 222 delete s_messageLoopInterruptor; | |
| 223 s_messageLoopInterruptor = 0; | |
| 224 } | 211 } |
| 225 | 212 |
| 226 // Shutdown V8-related background threads before V8 is ramped down. Note | 213 // Shutdown V8-related background threads before V8 is ramped down. Note |
| 227 // that this will wait the thread to stop its operations. | 214 // that this will wait the thread to stop its operations. |
| 228 ScriptStreamerThread::shutdown(); | 215 ScriptStreamerThread::shutdown(); |
| 229 | 216 |
| 230 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); | 217 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| 231 V8PerIsolateData::willBeDestroyed(isolate); | 218 V8PerIsolateData::willBeDestroyed(isolate); |
| 232 | 219 |
| 233 // Make sure we stop WorkerThreads before the main thread's ThreadState | 220 // Make sure we stop WorkerThreads before the main thread's ThreadState |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 ASSERT(!reloadPages); | 277 ASSERT(!reloadPages); |
| 291 Page::refreshPlugins(); | 278 Page::refreshPlugins(); |
| 292 } | 279 } |
| 293 | 280 |
| 294 void decommitFreeableMemory() | 281 void decommitFreeableMemory() |
| 295 { | 282 { |
| 296 WTF::Partitions::decommitFreeableMemory(); | 283 WTF::Partitions::decommitFreeableMemory(); |
| 297 } | 284 } |
| 298 | 285 |
| 299 } // namespace blink | 286 } // namespace blink |
| OLD | NEW |