| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 31 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 32 | 32 |
| 33 #include <v8.h> |
| 34 #include <memory> |
| 33 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/ScriptSourceCode.h" | 36 #include "bindings/core/v8/ScriptSourceCode.h" |
| 35 #include "bindings/core/v8/ScriptValue.h" | 37 #include "bindings/core/v8/ScriptValue.h" |
| 36 #include "bindings/core/v8/SourceLocation.h" | 38 #include "bindings/core/v8/SourceLocation.h" |
| 37 #include "bindings/core/v8/V8DOMWrapper.h" | 39 #include "bindings/core/v8/V8DOMWrapper.h" |
| 38 #include "bindings/core/v8/V8ErrorHandler.h" | 40 #include "bindings/core/v8/V8ErrorHandler.h" |
| 39 #include "bindings/core/v8/V8Initializer.h" | 41 #include "bindings/core/v8/V8Initializer.h" |
| 40 #include "bindings/core/v8/V8ObjectConstructor.h" | 42 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 41 #include "bindings/core/v8/V8ScriptRunner.h" | 43 #include "bindings/core/v8/V8ScriptRunner.h" |
| 42 #include "bindings/core/v8/WrapperTypeInfo.h" | 44 #include "bindings/core/v8/WrapperTypeInfo.h" |
| 43 #include "core/events/ErrorEvent.h" | 45 #include "core/events/ErrorEvent.h" |
| 44 #include "core/inspector/InspectorTraceEvents.h" | 46 #include "core/inspector/InspectorTraceEvents.h" |
| 45 #include "core/inspector/WorkerThreadDebugger.h" | 47 #include "core/inspector/WorkerThreadDebugger.h" |
| 46 #include "core/workers/WorkerGlobalScope.h" | 48 #include "core/workers/WorkerGlobalScope.h" |
| 47 #include "core/workers/WorkerOrWorkletGlobalScope.h" | 49 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
| 48 #include "core/workers/WorkerThread.h" | 50 #include "core/workers/WorkerThread.h" |
| 49 #include "platform/heap/ThreadState.h" | 51 #include "platform/heap/ThreadState.h" |
| 50 #include "public/platform/Platform.h" | 52 #include "public/platform/Platform.h" |
| 51 #include <memory> | |
| 52 #include <v8.h> | |
| 53 | 53 |
| 54 namespace blink { | 54 namespace blink { |
| 55 | 55 |
| 56 class WorkerOrWorkletScriptController::ExecutionState final { | 56 class WorkerOrWorkletScriptController::ExecutionState final { |
| 57 STACK_ALLOCATED(); | 57 STACK_ALLOCATED(); |
| 58 | 58 |
| 59 public: | 59 public: |
| 60 explicit ExecutionState(WorkerOrWorkletScriptController* controller) | 60 explicit ExecutionState(WorkerOrWorkletScriptController* controller) |
| 61 : hadException(false), | 61 : hadException(false), |
| 62 m_controller(controller), | 62 m_controller(controller), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // c) global object --> worker or worklet instance | 196 // c) global object --> worker or worklet instance |
| 197 // The global proxy object is NOT considered as a wrapper object of the | 197 // The global proxy object is NOT considered as a wrapper object of the |
| 198 // worker or worklet instance because it's not an instance of | 198 // worker or worklet instance because it's not an instance of |
| 199 // v8::FunctionTemplate of worker or worklet, especially note that | 199 // v8::FunctionTemplate of worker or worklet, especially note that |
| 200 // v8::Object::FindInstanceInPrototypeChain skips the global proxy object. | 200 // v8::Object::FindInstanceInPrototypeChain skips the global proxy object. |
| 201 // Thus we need to map the global object to the worker or worklet instance. | 201 // Thus we need to map the global object to the worker or worklet instance. |
| 202 | 202 |
| 203 // The global proxy object. Note this is not the global object. | 203 // The global proxy object. Note this is not the global object. |
| 204 v8::Local<v8::Object> globalProxy = context->Global(); | 204 v8::Local<v8::Object> globalProxy = context->Global(); |
| 205 v8::Local<v8::Object> associatedWrapper = | 205 v8::Local<v8::Object> associatedWrapper = |
| 206 V8DOMWrapper::associateObjectWithWrapper( | 206 V8DOMWrapper::associateObjectWithWrapper(m_isolate, scriptWrappable, |
| 207 m_isolate, scriptWrappable, wrapperTypeInfo, globalProxy); | 207 wrapperTypeInfo, globalProxy); |
| 208 CHECK(globalProxy == associatedWrapper); | 208 CHECK(globalProxy == associatedWrapper); |
| 209 | 209 |
| 210 // The global object, aka worker/worklet wrapper object. | 210 // The global object, aka worker/worklet wrapper object. |
| 211 v8::Local<v8::Object> globalObject = | 211 v8::Local<v8::Object> globalObject = |
| 212 globalProxy->GetPrototype().As<v8::Object>(); | 212 globalProxy->GetPrototype().As<v8::Object>(); |
| 213 V8DOMWrapper::setNativeInfo(m_isolate, globalObject, wrapperTypeInfo, | 213 V8DOMWrapper::setNativeInfo(m_isolate, globalObject, wrapperTypeInfo, |
| 214 scriptWrappable); | 214 scriptWrappable); |
| 215 | 215 |
| 216 // All interfaces must be registered to V8PerContextData. | 216 // All interfaces must be registered to V8PerContextData. |
| 217 // So we explicitly call constructorForType for the global object. | 217 // So we explicitly call constructorForType for the global object. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 m_executionState->m_errorEventFromImportedScript = errorEvent; | 352 m_executionState->m_errorEventFromImportedScript = errorEvent; |
| 353 exceptionState.rethrowV8Exception( | 353 exceptionState.rethrowV8Exception( |
| 354 V8ThrowException::createError(m_isolate, errorMessage)); | 354 V8ThrowException::createError(m_isolate, errorMessage)); |
| 355 } | 355 } |
| 356 | 356 |
| 357 DEFINE_TRACE(WorkerOrWorkletScriptController) { | 357 DEFINE_TRACE(WorkerOrWorkletScriptController) { |
| 358 visitor->trace(m_globalScope); | 358 visitor->trace(m_globalScope); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |