OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/testing/ReadableStreamTestRequest.h" |
| 7 |
| 8 #include "bindings/core/v8/ToV8.h" |
| 9 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "bindings/core/v8/V8HiddenValue.h" |
| 11 #include "core/streams/ReadableStream2.h" |
| 12 #include <v8.h> |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 ReadableStreamTestRequest::ReadableStreamTestRequest(ScriptState* scriptState, U
nderlyingSourceBase* underlyingSource) |
| 17 { |
| 18 ScriptState::Scope scope(scriptState); |
| 19 |
| 20 v8::Local<v8::Context> context = scriptState->context(); |
| 21 v8::Local<v8::Object> global = context->Global(); |
| 22 v8::Isolate* isolate = scriptState->isolate(); |
| 23 v8::Local<v8::Object> jsRequest = toV8(this, global, isolate).As<v8::Object>
(); |
| 24 |
| 25 ScriptValue strategy = JSStreams::createCountQueuingStrategy(scriptState, 10
); |
| 26 ScriptValue stream = JSStreams::createReadableStream(scriptState, underlying
Source, strategy); |
| 27 |
| 28 V8HiddenValue::setHiddenValue(isolate, jsRequest, V8HiddenValue::bodyStream(
isolate), stream.v8Value()); |
| 29 } |
| 30 |
| 31 ScriptValue ReadableStreamTestRequest::body(ScriptState* scriptState) |
| 32 { |
| 33 ScriptState::Scope scope(scriptState); |
| 34 v8::Isolate* isolate = scriptState->isolate(); |
| 35 v8::Local<v8::Object> global = scriptState->context()->Global(); |
| 36 v8::Local<v8::Object> jsRequest = toV8(this, global, isolate).As<v8::Object>
(); |
| 37 |
| 38 v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(isolate, jsReque
st, V8HiddenValue::bodyStream(isolate)); |
| 39 |
| 40 return ScriptValue(scriptState, result); |
| 41 } |
| 42 |
| 43 } |
OLD | NEW |