| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BytesConsumerTestUtil_h | 5 #ifndef BytesConsumerTestUtil_h |
| 6 #define BytesConsumerTestUtil_h | 6 #define BytesConsumerTestUtil_h |
| 7 | 7 |
| 8 #include "modules/fetch/BytesConsumer.h" | 8 #include "modules/fetch/BytesConsumer.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "wtf/Deque.h" | 10 #include "wtf/Deque.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 Member<ExecutionContext> m_executionContext; | 76 Member<ExecutionContext> m_executionContext; |
| 77 Member<BytesConsumer::Client> m_client; | 77 Member<BytesConsumer::Client> m_client; |
| 78 InternalState m_state = InternalState::Waiting; | 78 InternalState m_state = InternalState::Waiting; |
| 79 Deque<Command> m_commands; | 79 Deque<Command> m_commands; |
| 80 size_t m_offset = 0; | 80 size_t m_offset = 0; |
| 81 BytesConsumer::Error m_error; | 81 BytesConsumer::Error m_error; |
| 82 int m_notificationToken = 0; | 82 int m_notificationToken = 0; |
| 83 bool m_isCancelled = false; | 83 bool m_isCancelled = false; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 class Reader final : public GarbageCollectedFinalized<Reader>, public BytesC
onsumer::Client { | |
| 87 USING_GARBAGE_COLLECTED_MIXIN(Reader); | |
| 88 public: | |
| 89 // |consumer| must not have a client when called. | |
| 90 explicit Reader(BytesConsumer* /* consumer */); | |
| 91 | |
| 92 void onStateChange() override; | |
| 93 std::pair<BytesConsumer::Result, Vector<char>> run(); | |
| 94 | |
| 95 DEFINE_INLINE_TRACE() | |
| 96 { | |
| 97 visitor->trace(m_consumer); | |
| 98 BytesConsumer::Client::trace(visitor); | |
| 99 } | |
| 100 | |
| 101 private: | |
| 102 Member<BytesConsumer> m_consumer; | |
| 103 BytesConsumer::Result m_result = BytesConsumer::Result::ShouldWait; | |
| 104 Vector<char> m_data; | |
| 105 }; | |
| 106 | |
| 107 class TwoPhaseReader final : public GarbageCollectedFinalized<TwoPhaseReader
>, public BytesConsumer::Client { | 86 class TwoPhaseReader final : public GarbageCollectedFinalized<TwoPhaseReader
>, public BytesConsumer::Client { |
| 108 USING_GARBAGE_COLLECTED_MIXIN(TwoPhaseReader); | 87 USING_GARBAGE_COLLECTED_MIXIN(TwoPhaseReader); |
| 109 public: | 88 public: |
| 110 // |consumer| must not have a client when called. | 89 // |consumer| must not have a client when called. |
| 111 explicit TwoPhaseReader(BytesConsumer* /* consumer */); | 90 explicit TwoPhaseReader(BytesConsumer* /* consumer */); |
| 112 | 91 |
| 113 void onStateChange() override; | 92 void onStateChange() override; |
| 114 std::pair<BytesConsumer::Result, Vector<char>> run(); | 93 std::pair<BytesConsumer::Result, Vector<char>> run(); |
| 115 | 94 |
| 116 DEFINE_INLINE_TRACE() | 95 DEFINE_INLINE_TRACE() |
| 117 { | 96 { |
| 118 visitor->trace(m_consumer); | 97 visitor->trace(m_consumer); |
| 119 BytesConsumer::Client::trace(visitor); | 98 BytesConsumer::Client::trace(visitor); |
| 120 } | 99 } |
| 121 | 100 |
| 122 private: | 101 private: |
| 123 Member<BytesConsumer> m_consumer; | 102 Member<BytesConsumer> m_consumer; |
| 124 BytesConsumer::Result m_result = BytesConsumer::Result::ShouldWait; | 103 BytesConsumer::Result m_result = BytesConsumer::Result::ShouldWait; |
| 125 Vector<char> m_data; | 104 Vector<char> m_data; |
| 126 }; | 105 }; |
| 127 }; | 106 }; |
| 128 | 107 |
| 129 } // namespace blink | 108 } // namespace blink |
| 130 | 109 |
| 131 #endif // BytesConsumerTestUtil_h | 110 #endif // BytesConsumerTestUtil_h |
| OLD | NEW |