Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1076)

Side by Side Diff: Source/core/testing/ReadableStreamTestRequest.cpp

Issue 1167343002: Add methods for creating V8 extras-based ReadableStreams from C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: That todo is not necessary according to yhirano@ Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « Source/core/testing/ReadableStreamTestRequest.h ('k') | Source/core/testing/ReadableStreamTestRequest.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698