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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/core/streams/StreamTest.h ('k') | Source/core/streams/StreamTest.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/streams/ScriptQueuingStrategy.h"
7 #include "core/streams/ScriptUnderlyingSource.h"
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "core/streams/StreamTest.h"
10 #include <v8.h>
11
12 namespace blink {
13
14 class TestUnderlyingSource : public ScriptUnderlyingSource {
15 public:
16 TestUnderlyingSource(ScriptState* state) : m_scriptState(state) { };
17
18 ScriptPromise startImpl() override
19 {
20 controller().close();
21 return ScriptPromise::cast(m_scriptState, ScriptValue::createNull(m_scri ptState));
22 // Use controller().enqueue(), controller().close(), controller().error( )
23 };
24 ScriptPromise pullImpl() override
25 {
26 return ScriptPromise::cast(m_scriptState, ScriptValue::createNull(m_scri ptState));
27 // Use controller().enqueue(), controller().close(), controller().error( )
28 };
29 ScriptPromise cancelImpl(ScriptValue reason) override
30 {
31 return ScriptPromise::cast(m_scriptState, ScriptValue::createNull(m_scri ptState));
32 // Do any cancel stuff, maybe using reason.
33 };
34
35 private:
36 ScriptState* m_scriptState;
37 };
38
39 class TestQueuingStrategy : public ScriptQueuingStrategy {
40 public:
41 // using ScriptQueuingStrategy::ScriptQueuingStrategy;
42 TestQueuingStrategy(double hwm) : ScriptQueuingStrategy(hwm) { };
43
44 double size(ScriptValue chunk) override {
45 return 0;
46 }
47 };
48
49 ScriptReadableStream StreamTest::test(ScriptState* scriptState)
50 {
51 // Aaaaah I have no idea how C++ works :( pointers :(
52 auto us = new TestUnderlyingSource(scriptState);
53 auto qs = new TestQueuingStrategy(1024.0);
54 return ScriptReadableStream(scriptState, us, qs);
55 }
56
57 DEFINE_TRACE(StreamTest)
58 {
59 }
60
61 }
OLDNEW
« 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