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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.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: Rebase on smaller CLs; move ReadableStreamController Created 4 years, 11 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/core/v8/ReadableStreamOperations.h" 5 #include "bindings/core/v8/ReadableStreamOperations.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/ToV8.h"
9 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
11 #include "bindings/core/v8/V8RecursionScope.h"
12 #include "core/streams/UnderlyingSourceBase.h"
10 13
11 namespace blink { 14 namespace blink {
12 15
16 ScriptValue ReadableStreamOperations::createReadableStream(ScriptState* scriptSt ate, UnderlyingSourceBase* underlyingSource, ScriptValue strategy)
17 {
18 ScriptState::Scope scope(scriptState);
19
20 v8::Local<v8::Value> jsUnderlyingSource = toV8(underlyingSource, scriptState );
21 v8::Local<v8::Value> jsStrategy = strategy.v8Value();
22
23 V8RecursionScope::MicrotaskSuppression mtsScope(scriptState->isolate());
haraken 2016/01/25 00:13:29 Maybe it would make sense to create another versio
domenic 2016/02/02 22:59:55 Aren't all V8 extra functions internal functions?
24 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy };
25 v8::Local<v8::Value> jsStream = v8CallExtraOrCrash(scriptState, "createReada bleStreamWithExternalController", args);
26
27 return ScriptValue(scriptState, jsStream);
28 }
29
30 ScriptValue ReadableStreamOperations::createCountQueuingStrategy(ScriptState* sc riptState, size_t highWaterMark)
31 {
32 ScriptState::Scope scope(scriptState);
33 v8::Isolate* isolate = scriptState->isolate();
34
35 v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) };
36 v8::Local<v8::Value> jsStrategy = v8CallExtraOrCrash(scriptState, "createBui ltInCountQueuingStrategy", args);
37
38 return ScriptValue(scriptState, jsStrategy);
39 }
40
13 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script Value stream, ExceptionState& es) 41 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script Value stream, ExceptionState& es)
14 { 42 {
15 ASSERT(isReadableStream(scriptState, stream)); 43 ASSERT(isReadableStream(scriptState, stream));
16 44
17 v8::TryCatch block(scriptState->isolate()); 45 v8::TryCatch block(scriptState->isolate());
18 v8::Local<v8::Value> args[] = { stream.v8Value() }; 46 v8::Local<v8::Value> args[] = { stream.v8Value() };
19 ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStr eamReader", args)); 47 ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStr eamReader", args));
20 if (block.HasCaught()) 48 if (block.HasCaught())
21 es.rethrowV8Exception(block.Exception()); 49 es.rethrowV8Exception(block.Exception());
22 return result; 50 return result;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal ue reader) 91 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal ue reader)
64 { 92 {
65 ASSERT(isReadableStreamReader(scriptState, reader)); 93 ASSERT(isReadableStreamReader(scriptState, reader));
66 94
67 v8::Local<v8::Value> args[] = { reader.v8Value() }; 95 v8::Local<v8::Value> args[] = { reader.v8Value() };
68 return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "Rea dFromReadableStreamReader", args)); 96 return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "Rea dFromReadableStreamReader", args));
69 } 97 }
70 98
71 } // namespace blink 99 } // namespace blink
72 100
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698