| 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 "modules/fetch/FetchDataLoader.h" | 9 #include "modules/fetch/FetchDataLoader.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // ReplayingBytesConsumer stores commands via |add| and replays the stored | 101 // ReplayingBytesConsumer stores commands via |add| and replays the stored |
| 102 // commends when read. | 102 // commends when read. |
| 103 class ReplayingBytesConsumer final : public BytesConsumer { | 103 class ReplayingBytesConsumer final : public BytesConsumer { |
| 104 public: | 104 public: |
| 105 // The ExecutionContext is needed to get a WebTaskRunner. | 105 // The ExecutionContext is needed to get a WebTaskRunner. |
| 106 explicit ReplayingBytesConsumer(ExecutionContext*); | 106 explicit ReplayingBytesConsumer(ExecutionContext*); |
| 107 ~ReplayingBytesConsumer(); | 107 ~ReplayingBytesConsumer(); |
| 108 | 108 |
| 109 // Add a command to this handle. This function must be called BEFORE | 109 // Add a command to this handle. This function must be called BEFORE |
| 110 // any BytesConsumer methods are called. | 110 // any BytesConsumer methods are called. |
| 111 void add(const Command& command) { m_commands.append(command); } | 111 void add(const Command& command) { m_commands.push_back(command); } |
| 112 | 112 |
| 113 Result beginRead(const char** buffer, size_t* available) override; | 113 Result beginRead(const char** buffer, size_t* available) override; |
| 114 Result endRead(size_t readSize) override; | 114 Result endRead(size_t readSize) override; |
| 115 | 115 |
| 116 void setClient(Client*) override; | 116 void setClient(Client*) override; |
| 117 void clearClient() override; | 117 void clearClient() override; |
| 118 void cancel() override; | 118 void cancel() override; |
| 119 PublicState getPublicState() const override; | 119 PublicState getPublicState() const override; |
| 120 Error getError() const override; | 120 Error getError() const override; |
| 121 String debugName() const override { return "ReplayingBytesConsumer"; } | 121 String debugName() const override { return "ReplayingBytesConsumer"; } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 private: | 158 private: |
| 159 Member<BytesConsumer> m_consumer; | 159 Member<BytesConsumer> m_consumer; |
| 160 BytesConsumer::Result m_result = BytesConsumer::Result::ShouldWait; | 160 BytesConsumer::Result m_result = BytesConsumer::Result::ShouldWait; |
| 161 Vector<char> m_data; | 161 Vector<char> m_data; |
| 162 }; | 162 }; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 } // namespace blink | 165 } // namespace blink |
| 166 | 166 |
| 167 #endif // BytesConsumerTestUtil_h | 167 #endif // BytesConsumerTestUtil_h |
| OLD | NEW |