Chromium Code Reviews

Unified 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.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « Source/core/testing/ReadableStreamTestRequest.h ('k') | Source/core/testing/ReadableStreamTestRequest.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/ReadableStreamTestRequest.cpp
diff --git a/Source/core/testing/ReadableStreamTestRequest.cpp b/Source/core/testing/ReadableStreamTestRequest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bd11fac0c11f8b9f88de963023de79f64df75370
--- /dev/null
+++ b/Source/core/testing/ReadableStreamTestRequest.cpp
@@ -0,0 +1,43 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/testing/ReadableStreamTestRequest.h"
+
+#include "bindings/core/v8/ToV8.h"
+#include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8HiddenValue.h"
+#include "core/streams/ReadableStream2.h"
+#include <v8.h>
+
+namespace blink {
+
+ReadableStreamTestRequest::ReadableStreamTestRequest(ScriptState* scriptState, UnderlyingSourceBase* underlyingSource)
+{
+ ScriptState::Scope scope(scriptState);
+
+ v8::Local<v8::Context> context = scriptState->context();
+ v8::Local<v8::Object> global = context->Global();
+ v8::Isolate* isolate = scriptState->isolate();
+ v8::Local<v8::Object> jsRequest = toV8(this, global, isolate).As<v8::Object>();
+
+ ScriptValue strategy = JSStreams::createCountQueuingStrategy(scriptState, 10);
+ ScriptValue stream = JSStreams::createReadableStream(scriptState, underlyingSource, strategy);
+
+ V8HiddenValue::setHiddenValue(isolate, jsRequest, V8HiddenValue::bodyStream(isolate), stream.v8Value());
+}
+
+ScriptValue ReadableStreamTestRequest::body(ScriptState* scriptState)
+{
+ ScriptState::Scope scope(scriptState);
+ v8::Isolate* isolate = scriptState->isolate();
+ v8::Local<v8::Object> global = scriptState->context()->Global();
+ v8::Local<v8::Object> jsRequest = toV8(this, global, isolate).As<v8::Object>();
+
+ v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(isolate, jsRequest, V8HiddenValue::bodyStream(isolate));
+
+ return ScriptValue(scriptState, result);
+}
+
+}
« 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