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

Unified Diff: Source/core/streams/StreamTest.cpp

Issue 1118673002: Implement ReadableStream as a V8 extra (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Cleanups; make controller a member instead of arg Created 5 years, 7 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
« no previous file with comments | « Source/core/streams/StreamTest.h ('k') | Source/core/streams/StreamTest.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/streams/StreamTest.cpp
diff --git a/Source/core/streams/StreamTest.cpp b/Source/core/streams/StreamTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e312f2a40a522ab6d7d77ba365becfdd4c2efd7a
--- /dev/null
+++ b/Source/core/streams/StreamTest.cpp
@@ -0,0 +1,61 @@
+// 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/streams/ScriptQueuingStrategy.h"
+#include "core/streams/ScriptUnderlyingSource.h"
+#include "bindings/core/v8/ScriptPromise.h"
+#include "core/streams/StreamTest.h"
+#include <v8.h>
+
+namespace blink {
+
+class TestUnderlyingSource : public ScriptUnderlyingSource {
+public:
+ TestUnderlyingSource(ScriptState* state) : m_scriptState(state) { };
+
+ ScriptPromise startImpl() override
+ {
+ controller().close();
+ return ScriptPromise::cast(m_scriptState, ScriptValue::createNull(m_scriptState));
+ // Use controller().enqueue(), controller().close(), controller().error()
+ };
+ ScriptPromise pullImpl() override
+ {
+ return ScriptPromise::cast(m_scriptState, ScriptValue::createNull(m_scriptState));
+ // Use controller().enqueue(), controller().close(), controller().error()
+ };
+ ScriptPromise cancelImpl(ScriptValue reason) override
+ {
+ return ScriptPromise::cast(m_scriptState, ScriptValue::createNull(m_scriptState));
+ // Do any cancel stuff, maybe using reason.
+ };
+
+private:
+ ScriptState* m_scriptState;
+};
+
+class TestQueuingStrategy : public ScriptQueuingStrategy {
+public:
+// using ScriptQueuingStrategy::ScriptQueuingStrategy;
+ TestQueuingStrategy(double hwm) : ScriptQueuingStrategy(hwm) { };
+
+ double size(ScriptValue chunk) override {
+ return 0;
+ }
+};
+
+ScriptReadableStream StreamTest::test(ScriptState* scriptState)
+{
+ // Aaaaah I have no idea how C++ works :( pointers :(
+ auto us = new TestUnderlyingSource(scriptState);
+ auto qs = new TestQueuingStrategy(1024.0);
+ return ScriptReadableStream(scriptState, us, qs);
+}
+
+DEFINE_TRACE(StreamTest)
+{
+}
+
+}
« no previous file with comments | « Source/core/streams/StreamTest.h ('k') | Source/core/streams/StreamTest.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698