| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 static WebThread::TaskObserver* s_endOfTaskRunner = 0; | 86 static WebThread::TaskObserver* s_endOfTaskRunner = 0; |
| 87 static WebThread::TaskObserver* s_pendingGCRunner = 0; | 87 static WebThread::TaskObserver* s_pendingGCRunner = 0; |
| 88 static ThreadState::Interruptor* s_messageLoopInterruptor = 0; | 88 static ThreadState::Interruptor* s_messageLoopInterruptor = 0; |
| 89 static ThreadState::Interruptor* s_isolateInterruptor = 0; | 89 static ThreadState::Interruptor* s_isolateInterruptor = 0; |
| 90 | 90 |
| 91 // Make sure we are not re-initialized in the same address space. | 91 // Make sure we are not re-initialized in the same address space. |
| 92 // Doing so may cause hard to reproduce crashes. | 92 // Doing so may cause hard to reproduce crashes. |
| 93 static bool s_webKitInitialized = false; | 93 static bool s_webKitInitialized = false; |
| 94 | 94 |
| 95 static bool generateEntropy(unsigned char* buffer, size_t length) | |
| 96 { | |
| 97 if (Platform::current()) { | |
| 98 Platform::current()->cryptographicallyRandomValues(buffer, length); | |
| 99 return true; | |
| 100 } | |
| 101 return false; | |
| 102 } | |
| 103 | |
| 104 void initialize(Platform* platform) | 95 void initialize(Platform* platform) |
| 105 { | 96 { |
| 106 initializeWithoutV8(platform); | 97 initializeWithoutV8(platform); |
| 107 | 98 |
| 108 v8::V8::InitializePlatform(gin::V8Platform::Get()); | 99 V8Initializer::initializeMainThreadIfNeeded(); |
| 109 v8::Isolate* isolate = v8::Isolate::New(); | |
| 110 isolate->Enter(); | |
| 111 V8Initializer::initializeMainThreadIfNeeded(isolate); | |
| 112 v8::V8::SetEntropySource(&generateEntropy); | |
| 113 v8::V8::SetArrayBufferAllocator(v8ArrayBufferAllocator()); | |
| 114 v8::V8::Initialize(); | |
| 115 V8PerIsolateData::ensureInitialized(isolate); | |
| 116 | 100 |
| 117 s_isolateInterruptor = new V8IsolateInterruptor(v8::Isolate::GetCurrent()); | 101 s_isolateInterruptor = new V8IsolateInterruptor(V8PerIsolateData::mainThread
Isolate()); |
| 118 ThreadState::current()->addInterruptor(s_isolateInterruptor); | 102 ThreadState::current()->addInterruptor(s_isolateInterruptor); |
| 119 | 103 |
| 120 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. | 104 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. |
| 121 if (WebThread* currentThread = platform->currentThread()) { | 105 if (WebThread* currentThread = platform->currentThread()) { |
| 122 ASSERT(!s_endOfTaskRunner); | 106 ASSERT(!s_endOfTaskRunner); |
| 123 s_endOfTaskRunner = new EndOfTaskRunner; | 107 s_endOfTaskRunner = new EndOfTaskRunner; |
| 124 currentThread->addTaskObserver(s_endOfTaskRunner); | 108 currentThread->addTaskObserver(s_endOfTaskRunner); |
| 125 } | 109 } |
| 126 } | 110 } |
| 127 | 111 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 delete s_messageLoopInterruptor; | 201 delete s_messageLoopInterruptor; |
| 218 s_messageLoopInterruptor = 0; | 202 s_messageLoopInterruptor = 0; |
| 219 } | 203 } |
| 220 | 204 |
| 221 // Detach the main thread before starting the shutdown sequence | 205 // Detach the main thread before starting the shutdown sequence |
| 222 // so that the main thread won't get involved in a GC during the shutdown. | 206 // so that the main thread won't get involved in a GC during the shutdown. |
| 223 ThreadState::detachMainThread(); | 207 ThreadState::detachMainThread(); |
| 224 | 208 |
| 225 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); | 209 v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); |
| 226 V8PerIsolateData::dispose(isolate); | 210 V8PerIsolateData::dispose(isolate); |
| 227 isolate->Exit(); | |
| 228 isolate->Dispose(); | |
| 229 | 211 |
| 230 shutdownWithoutV8(); | 212 shutdownWithoutV8(); |
| 231 } | 213 } |
| 232 | 214 |
| 233 void shutdownWithoutV8() | 215 void shutdownWithoutV8() |
| 234 { | 216 { |
| 235 ASSERT(!s_endOfTaskRunner); | 217 ASSERT(!s_endOfTaskRunner); |
| 236 CoreInitializer::shutdown(); | 218 CoreInitializer::shutdown(); |
| 237 Scheduler::shutdown(); | 219 Scheduler::shutdown(); |
| 238 Heap::shutdown(); | 220 Heap::shutdown(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 269 channel->state = WTFLogChannelOn; | 251 channel->state = WTFLogChannelOn; |
| 270 #endif // !LOG_DISABLED | 252 #endif // !LOG_DISABLED |
| 271 } | 253 } |
| 272 | 254 |
| 273 void resetPluginCache(bool reloadPages) | 255 void resetPluginCache(bool reloadPages) |
| 274 { | 256 { |
| 275 Page::refreshPlugins(reloadPages); | 257 Page::refreshPlugins(reloadPages); |
| 276 } | 258 } |
| 277 | 259 |
| 278 } // namespace blink | 260 } // namespace blink |
| OLD | NEW |