OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/modules/v8/wasm/WasmResponseExtensions.h" | 5 #include "bindings/modules/v8/wasm/WasmResponseExtensions.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
11 #include "bindings/modules/v8/V8Response.h" | 11 #include "bindings/modules/v8/V8Response.h" |
| 12 #include "core/dom/ExecutionContext.h" |
12 #include "modules/fetch/BodyStreamBuffer.h" | 13 #include "modules/fetch/BodyStreamBuffer.h" |
13 #include "modules/fetch/FetchDataLoader.h" | 14 #include "modules/fetch/FetchDataLoader.h" |
14 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
15 #include "wtf/RefPtr.h" | 16 #include "wtf/RefPtr.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 class FetchDataLoaderAsWasmModule final : public FetchDataLoader, | 22 class FetchDataLoaderAsWasmModule final : public FetchDataLoader, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // See | 143 // See |
143 // https://github.com/WebAssembly/design/blob/master/Web.md#webassemblycompile | 144 // https://github.com/WebAssembly/design/blob/master/Web.md#webassemblycompile |
144 void CompileFromResponseCallback( | 145 void CompileFromResponseCallback( |
145 const v8::FunctionCallbackInfo<v8::Value>& args) { | 146 const v8::FunctionCallbackInfo<v8::Value>& args) { |
146 ExceptionState exception_state(args.GetIsolate(), | 147 ExceptionState exception_state(args.GetIsolate(), |
147 ExceptionState::kExecutionContext, | 148 ExceptionState::kExecutionContext, |
148 "WebAssembly", "compile"); | 149 "WebAssembly", "compile"); |
149 ExceptionToRejectPromiseScope reject_promise_scope(args, exception_state); | 150 ExceptionToRejectPromiseScope reject_promise_scope(args, exception_state); |
150 | 151 |
151 ScriptState* script_state = ScriptState::ForReceiverObject(args); | 152 ScriptState* script_state = ScriptState::ForReceiverObject(args); |
152 if (!script_state->GetExecutionContext()) { | 153 if (!ExecutionContext::From(script_state)) { |
153 V8SetReturnValue(args, ScriptPromise().V8Value()); | 154 V8SetReturnValue(args, ScriptPromise().V8Value()); |
154 return; | 155 return; |
155 } | 156 } |
156 | 157 |
157 if (args.Length() < 1 || !args[0]->IsObject() || | 158 if (args.Length() < 1 || !args[0]->IsObject() || |
158 !V8Response::hasInstance(args[0], args.GetIsolate())) { | 159 !V8Response::hasInstance(args[0], args.GetIsolate())) { |
159 V8SetReturnValue( | 160 V8SetReturnValue( |
160 args, ScriptPromise::Reject( | 161 args, ScriptPromise::Reject( |
161 script_state, V8ThrowException::CreateTypeError( | 162 script_state, V8ThrowException::CreateTypeError( |
162 script_state->GetIsolate(), | 163 script_state->GetIsolate(), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 return true; | 221 return true; |
221 } | 222 } |
222 | 223 |
223 } // namespace | 224 } // namespace |
224 | 225 |
225 void WasmResponseExtensions::Initialize(v8::Isolate* isolate) { | 226 void WasmResponseExtensions::Initialize(v8::Isolate* isolate) { |
226 isolate->SetWasmCompileCallback(WasmCompileOverload); | 227 isolate->SetWasmCompileCallback(WasmCompileOverload); |
227 } | 228 } |
228 | 229 |
229 } // namespace blink | 230 } // namespace blink |
OLD | NEW |