| 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 25 matching lines...) Expand all Loading... |
| 36 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" | 36 #include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h" |
| 37 #include "bindings/core/v8/V8ErrorHandler.h" | 37 #include "bindings/core/v8/V8ErrorHandler.h" |
| 38 #include "bindings/core/v8/V8Initializer.h" | 38 #include "bindings/core/v8/V8Initializer.h" |
| 39 #include "bindings/core/v8/V8ObjectConstructor.h" | 39 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 40 #include "bindings/core/v8/V8ScriptRunner.h" | 40 #include "bindings/core/v8/V8ScriptRunner.h" |
| 41 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" | 41 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" |
| 42 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 42 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
| 43 #include "bindings/core/v8/WrapperTypeInfo.h" | 43 #include "bindings/core/v8/WrapperTypeInfo.h" |
| 44 #include "core/events/ErrorEvent.h" | 44 #include "core/events/ErrorEvent.h" |
| 45 #include "core/frame/DOMTimer.h" | 45 #include "core/frame/DOMTimer.h" |
| 46 #include "core/inspector/MainThreadDebugger.h" |
| 46 #include "core/inspector/WorkerThreadDebugger.h" | 47 #include "core/inspector/WorkerThreadDebugger.h" |
| 48 #include "core/workers/MainThreadWorkletGlobalScope.h" |
| 47 #include "core/workers/WorkerObjectProxy.h" | 49 #include "core/workers/WorkerObjectProxy.h" |
| 48 #include "core/workers/WorkerOrWorkletGlobalScope.h" | 50 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
| 49 #include "core/workers/WorkerThread.h" | 51 #include "core/workers/WorkerThread.h" |
| 50 #include "platform/heap/ThreadState.h" | 52 #include "platform/heap/ThreadState.h" |
| 51 #include "public/platform/Platform.h" | 53 #include "public/platform/Platform.h" |
| 52 #include <v8.h> | 54 #include <v8.h> |
| 53 | 55 |
| 54 namespace blink { | 56 namespace blink { |
| 55 | 57 |
| 56 class WorkerOrWorkletScriptController::ExecutionState final { | 58 class WorkerOrWorkletScriptController::ExecutionState final { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return true; | 143 return true; |
| 142 | 144 |
| 143 v8::Local<v8::Context> context = v8::Context::New(m_isolate); | 145 v8::Local<v8::Context> context = v8::Context::New(m_isolate); |
| 144 if (context.IsEmpty()) | 146 if (context.IsEmpty()) |
| 145 return false; | 147 return false; |
| 146 | 148 |
| 147 m_scriptState = ScriptState::create(context, m_world); | 149 m_scriptState = ScriptState::create(context, m_world); |
| 148 | 150 |
| 149 ScriptState::Scope scope(m_scriptState.get()); | 151 ScriptState::Scope scope(m_scriptState.get()); |
| 150 | 152 |
| 151 // Name new context for debugging. | 153 // Name new context for debugging. For main thread worklet global scopes |
| 152 WorkerThreadDebugger::setContextDebugData(context); | 154 // this is done once the context is initialized. |
| 155 if (m_globalScope->isWorkerGlobalScope()) { |
| 156 WorkerThreadDebugger::setContextDebugData(context); |
| 157 } |
| 153 | 158 |
| 154 // Create a new JS object and use it as the prototype for the shadow global
object. | 159 // Create a new JS object and use it as the prototype for the shadow global
object. |
| 155 const WrapperTypeInfo* wrapperTypeInfo = m_globalScope->getScriptWrappable()
->wrapperTypeInfo(); | 160 const WrapperTypeInfo* wrapperTypeInfo = m_globalScope->getScriptWrappable()
->wrapperTypeInfo(); |
| 156 | 161 |
| 157 v8::Local<v8::Function> globalScopeConstructor = m_scriptState->perContextDa
ta()->constructorForType(wrapperTypeInfo); | 162 v8::Local<v8::Function> globalScopeConstructor = m_scriptState->perContextDa
ta()->constructorForType(wrapperTypeInfo); |
| 158 if (globalScopeConstructor.IsEmpty()) | 163 if (globalScopeConstructor.IsEmpty()) |
| 159 return false; | 164 return false; |
| 160 | 165 |
| 161 v8::Local<v8::Object> jsGlobalScope; | 166 v8::Local<v8::Object> jsGlobalScope; |
| 162 if (!V8ObjectConstructor::newInstance(m_isolate, globalScopeConstructor).ToL
ocal(&jsGlobalScope)) { | 167 if (!V8ObjectConstructor::newInstance(m_isolate, globalScopeConstructor).ToL
ocal(&jsGlobalScope)) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 m_executionState->m_errorEventFromImportedScript = errorEvent; | 303 m_executionState->m_errorEventFromImportedScript = errorEvent; |
| 299 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso
late, errorMessage)); | 304 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(m_iso
late, errorMessage)); |
| 300 } | 305 } |
| 301 | 306 |
| 302 DEFINE_TRACE(WorkerOrWorkletScriptController) | 307 DEFINE_TRACE(WorkerOrWorkletScriptController) |
| 303 { | 308 { |
| 304 visitor->trace(m_globalScope); | 309 visitor->trace(m_globalScope); |
| 305 } | 310 } |
| 306 | 311 |
| 307 } // namespace blink | 312 } // namespace blink |
| OLD | NEW |