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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp
index 36590becef6a1678e29cdf02e7882008aaee6b30..fd8ec52d030b97b149859346d17b6e0938056e46 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp
@@ -6,10 +6,38 @@
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/ToV8.h"
#include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8RecursionScope.h"
+#include "core/streams/UnderlyingSourceBase.h"
namespace blink {
+ScriptValue ReadableStreamOperations::createReadableStream(ScriptState* scriptState, UnderlyingSourceBase* underlyingSource, ScriptValue strategy)
+{
+ ScriptState::Scope scope(scriptState);
+
+ v8::Local<v8::Value> jsUnderlyingSource = toV8(underlyingSource, scriptState);
+ v8::Local<v8::Value> jsStrategy = strategy.v8Value();
+
+ 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?
+ v8::Local<v8::Value> args[] = { jsUnderlyingSource, jsStrategy };
+ v8::Local<v8::Value> jsStream = v8CallExtraOrCrash(scriptState, "createReadableStreamWithExternalController", args);
+
+ return ScriptValue(scriptState, jsStream);
+}
+
+ScriptValue ReadableStreamOperations::createCountQueuingStrategy(ScriptState* scriptState, size_t highWaterMark)
+{
+ ScriptState::Scope scope(scriptState);
+ v8::Isolate* isolate = scriptState->isolate();
+
+ v8::Local<v8::Value> args[] = { v8::Number::New(isolate, highWaterMark) };
+ v8::Local<v8::Value> jsStrategy = v8CallExtraOrCrash(scriptState, "createBuiltInCountQueuingStrategy", args);
+
+ return ScriptValue(scriptState, jsStrategy);
+}
+
ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, ScriptValue stream, ExceptionState& es)
{
ASSERT(isReadableStream(scriptState, stream));

Powered by Google App Engine
This is Rietveld 408576698