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

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: Trying blindly to resolve circular dependency Created 4 years, 10 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/V8ScriptRunner.h" 10 #include "bindings/core/v8/V8ScriptRunner.h"
11 #include "core/streams/UnderlyingSourceBase.h"
10 12
11 namespace blink { 13 namespace blink {
12 14
15 ScriptValue ReadableStreamOperations::createReadableStream(ScriptState* scriptSt ate, UnderlyingSourceBase* underlyingSource, ScriptValue strategy)
16 {
17 ScriptState::Scope scope(scriptState);
18
19 v8::Local<v8::Value> jsUnderlyingSource = toV8(underlyingSource, scriptState );
20 v8::Local<v8::Value> jsStrategy = strategy.v8Value();
21 v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy };
22 v8::Local<v8::Value> jsStream = V8ScriptRunner::callExtraOrCrash(scriptState , "createReadableStreamWithExternalController", args);
23
24 return ScriptValue(scriptState, jsStream);
25 }
26
27 ScriptValue ReadableStreamOperations::createCountQueuingStrategy(ScriptState* sc riptState, size_t highWaterMark)
28 {
29 ScriptState::Scope scope(scriptState);
30
31 v8::Local<v8::Value> args[] = { v8::Number::New(scriptState->isolate(), high WaterMark) };
32 v8::Local<v8::Value> jsStrategy = V8ScriptRunner::callExtraOrCrash(scriptSta te, "createBuiltInCountQueuingStrategy", args);
33
34 return ScriptValue(scriptState, jsStrategy);
35 }
36
13 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script Value stream, ExceptionState& es) 37 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script Value stream, ExceptionState& es)
14 { 38 {
15 ASSERT(isReadableStream(scriptState, stream)); 39 ASSERT(isReadableStream(scriptState, stream));
16 40
17 v8::TryCatch block(scriptState->isolate()); 41 v8::TryCatch block(scriptState->isolate());
18 v8::Local<v8::Value> args[] = { stream.v8Value() }; 42 v8::Local<v8::Value> args[] = { stream.v8Value() };
19 ScriptValue result(scriptState, V8ScriptRunner::callExtra(scriptState, "Acqu ireReadableStreamReader", args)); 43 ScriptValue result(scriptState, V8ScriptRunner::callExtra(scriptState, "Acqu ireReadableStreamReader", args));
20 if (block.HasCaught()) 44 if (block.HasCaught())
21 es.rethrowV8Exception(block.Exception()); 45 es.rethrowV8Exception(block.Exception());
22 return result; 46 return result;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal ue reader) 87 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal ue reader)
64 { 88 {
65 ASSERT(isReadableStreamReader(scriptState, reader)); 89 ASSERT(isReadableStreamReader(scriptState, reader));
66 90
67 v8::Local<v8::Value> args[] = { reader.v8Value() }; 91 v8::Local<v8::Value> args[] = { reader.v8Value() };
68 return ScriptPromise::cast(scriptState, V8ScriptRunner::callExtraOrCrash(scr iptState, "ReadFromReadableStreamReader", args)); 92 return ScriptPromise::cast(scriptState, V8ScriptRunner::callExtraOrCrash(scr iptState, "ReadFromReadableStreamReader", args));
69 } 93 }
70 94
71 } // namespace blink 95 } // namespace blink
72 96
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698