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

Side by Side Diff: Source/core/streams/ReadableStream2.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
« no previous file with comments | « Source/core/streams/ReadableStream2.h ('k') | Source/core/streams/ReadableStream2.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/streams/ReadableStream2.h"
7
8 #include "bindings/core/v8/ToV8.h"
9 #include "bindings/core/v8/V8RecursionScope.h"
10 #include "core/streams/UnderlyingSourceBase.h"
11 #include <v8.h>
12
13 namespace blink {
14
15 namespace JSStreams {
16
17 ScriptValue createReadableStream(ScriptState* scriptState, UnderlyingSourceBase* underlyingSource, ScriptValue strategy)
18 {
19 ScriptState::Scope scope(scriptState);
20 auto global = scriptState->context()->Global();
21 auto isolate = scriptState->isolate();
22
23 auto jsUnderlyingSource = toV8(underlyingSource, global, isolate);
24 auto jsStrategy = strategy.v8Value();
25
26 auto sentinel = scriptState->getFromExtrasExports("createWithExternalControl lerSentinel").v8Value();
27 auto constructor = scriptState->getFromExtrasExports("ReadableStream").v8Val ue().As<v8::Function>();
28
29 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy, sentinel };
30
31 V8RecursionScope::MicrotaskSuppression mtsScope(isolate);
32 auto jsStream = constructor->NewInstance(arraysize(args), args);
33
34 return ScriptValue(scriptState, jsStream);
35 }
36
37 ScriptValue createCountQueuingStrategy(ScriptState* scriptState, size_t highWate rMark)
38 {
39 ScriptState::Scope scope(scriptState);
40 auto isolate = scriptState->isolate();
41
42 auto constructor = scriptState->getFromExtrasExports("BuiltInCountQueuingStr ategy").v8Value().As<v8::Function>();
43
44 v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) };
45
46 V8RecursionScope::MicrotaskSuppression mtsScope(isolate);
47 auto jsStrategy = constructor->NewInstance(arraysize(args), args);
48
49 return ScriptValue(scriptState, jsStrategy);
50 }
51
52 } // namespace JSStreams
53
54 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/streams/ReadableStream2.h ('k') | Source/core/streams/ReadableStream2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698