OLD | NEW |
(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 } |
OLD | NEW |