Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 private: | 93 private: |
| 94 explicit IsolateCleanupTask(v8::Isolate* isolate) : m_isolate(isolate) { } | 94 explicit IsolateCleanupTask(v8::Isolate* isolate) : m_isolate(isolate) { } |
| 95 | 95 |
| 96 v8::Isolate* m_isolate; | 96 v8::Isolate* m_isolate; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 WorkerScriptController::~WorkerScriptController() | 99 WorkerScriptController::~WorkerScriptController() |
| 100 { | 100 { |
| 101 ThreadState::current()->removeInterruptor(m_interruptor.get()); | 101 ThreadState::current()->removeInterruptor(m_interruptor.get()); |
| 102 | 102 |
| 103 RELEASE_ASSERT(m_world->hasOneRef()); | |
| 104 // ~DOMWrapperWorld() must be called before disposing the isolate. | |
| 105 m_world = nullptr; | |
| 106 | |
| 107 // The corresponding call to didStartWorkerRunLoop is in | 103 // The corresponding call to didStartWorkerRunLoop is in |
| 108 // WorkerThread::workerThread(). | 104 // WorkerThread::workerThread(). |
| 109 // See http://webkit.org/b/83104#c14 for why this is here. | 105 // See http://webkit.org/b/83104#c14 for why this is here. |
| 110 blink::Platform::current()->didStopWorkerRunLoop(blink::WebWorkerRunLoop(&m_ workerGlobalScope.thread()->runLoop())); | 106 blink::Platform::current()->didStopWorkerRunLoop(blink::WebWorkerRunLoop(&m_ workerGlobalScope.thread()->runLoop())); |
| 111 | 107 |
| 112 disposeContext(); | 108 disposeContext(); |
| 113 | 109 |
| 110 m_world->dispose(); | |
|
haraken
2014/03/10 10:47:32
I noticed that m_world->dispose() must be executed
| |
| 111 | |
| 114 ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolate) ); | 112 ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolate) ); |
| 115 } | 113 } |
| 116 | 114 |
| 117 void WorkerScriptController::disposeContext() | 115 void WorkerScriptController::disposeContext() |
| 118 { | 116 { |
| 119 m_perContextData.clear(); | 117 m_perContextData.clear(); |
| 120 } | 118 } |
| 121 | 119 |
| 122 bool WorkerScriptController::initializeContextIfNeeded() | 120 bool WorkerScriptController::initializeContextIfNeeded() |
| 123 { | 121 { |
| 124 if (m_perContextData) | 122 if (m_perContextData) |
| 125 return true; | 123 return true; |
| 126 | 124 |
| 127 v8::Handle<v8::Context> context = v8::Context::New(m_isolate); | 125 v8::Handle<v8::Context> context = v8::Context::New(m_isolate); |
| 128 if (context.IsEmpty()) | 126 if (context.IsEmpty()) |
| 129 return false; | 127 return false; |
| 130 | 128 |
| 131 m_perContextData = V8PerContextData::create(context, m_world.get()); | 129 m_perContextData = V8PerContextData::create(context, m_world); |
| 132 | 130 |
| 133 v8::Context::Scope scope(context); | 131 v8::Context::Scope scope(context); |
| 134 | 132 |
| 135 // Set DebugId for the new context. | 133 // Set DebugId for the new context. |
| 136 context->SetEmbedderData(0, v8AtomicString(m_isolate, "worker")); | 134 context->SetEmbedderData(0, v8AtomicString(m_isolate, "worker")); |
| 137 | 135 |
| 138 // Create a new JS object and use it as the prototype for the shadow global object. | 136 // Create a new JS object and use it as the prototype for the shadow global object. |
| 139 const WrapperTypeInfo* contextType = &V8DedicatedWorkerGlobalScope::wrapperT ypeInfo; | 137 const WrapperTypeInfo* contextType = &V8DedicatedWorkerGlobalScope::wrapperT ypeInfo; |
| 140 if (m_workerGlobalScope.isServiceWorkerGlobalScope()) | 138 if (m_workerGlobalScope.isServiceWorkerGlobalScope()) |
| 141 contextType = &V8ServiceWorkerGlobalScope::wrapperTypeInfo; | 139 contextType = &V8ServiceWorkerGlobalScope::wrapperTypeInfo; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr <ErrorEvent>* errorEvent) | 204 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr <ErrorEvent>* errorEvent) |
| 207 { | 205 { |
| 208 if (isExecutionForbidden()) | 206 if (isExecutionForbidden()) |
| 209 return; | 207 return; |
| 210 | 208 |
| 211 WorkerGlobalScopeExecutionState state; | 209 WorkerGlobalScopeExecutionState state; |
| 212 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); | 210 evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPos ition(), &state); |
| 213 if (state.hadException) { | 211 if (state.hadException) { |
| 214 if (errorEvent) { | 212 if (errorEvent) { |
| 215 *errorEvent = m_workerGlobalScope.shouldSanitizeScriptError(state.so urceURL, NotSharableCrossOrigin) ? | 213 *errorEvent = m_workerGlobalScope.shouldSanitizeScriptError(state.so urceURL, NotSharableCrossOrigin) ? |
| 216 ErrorEvent::createSanitizedError(nullptr) : ErrorEvent::create(s tate.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, nullpt r); | 214 ErrorEvent::createSanitizedError(0) : ErrorEvent::create(state.e rrorMessage, state.sourceURL, state.lineNumber, state.columnNumber, 0); |
| 217 V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_isolate); | 215 V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_isolate); |
| 218 } else { | 216 } else { |
| 219 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin)); | 217 ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceUR L, NotSharableCrossOrigin)); |
| 220 RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorE ventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state. sourceURL, state.lineNumber, state.columnNumber, nullptr); | 218 RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorE ventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state. sourceURL, state.lineNumber, state.columnNumber, 0); |
| 221 m_workerGlobalScope.reportException(event, nullptr, NotSharableCross Origin); | 219 m_workerGlobalScope.reportException(event, nullptr, NotSharableCross Origin); |
| 222 } | 220 } |
| 223 } | 221 } |
| 224 } | 222 } |
| 225 | 223 |
| 226 void WorkerScriptController::scheduleExecutionTermination() | 224 void WorkerScriptController::scheduleExecutionTermination() |
| 227 { | 225 { |
| 228 // The mutex provides a memory barrier to ensure that once | 226 // The mutex provides a memory barrier to ensure that once |
| 229 // termination is scheduled, isExecutionTerminating will | 227 // termination is scheduled, isExecutionTerminating will |
| 230 // accurately reflect that state when called from another thread. | 228 // accurately reflect that state when called from another thread. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); | 271 v8::Handle<v8::Context> context = isolate->GetCurrentContext(); |
| 274 v8::Handle<v8::Object> global = V8WorkerGlobalScope::findInstanceInPrototype Chain(context->Global(), isolate); | 272 v8::Handle<v8::Object> global = V8WorkerGlobalScope::findInstanceInPrototype Chain(context->Global(), isolate); |
| 275 // Return 0 if the current executing context is not the worker context. | 273 // Return 0 if the current executing context is not the worker context. |
| 276 if (global.IsEmpty()) | 274 if (global.IsEmpty()) |
| 277 return 0; | 275 return 0; |
| 278 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global) ; | 276 WorkerGlobalScope* workerGlobalScope = V8WorkerGlobalScope::toNative(global) ; |
| 279 return workerGlobalScope->script(); | 277 return workerGlobalScope->script(); |
| 280 } | 278 } |
| 281 | 279 |
| 282 } // namespace WebCore | 280 } // namespace WebCore |
| OLD | NEW |