| 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 BytesConsumer_h | 5 #ifndef BytesConsumer_h |
| 6 #define BytesConsumer_h | 6 #define BytesConsumer_h |
| 7 | 7 |
| 8 #include "modules/ModulesExport.h" | 8 #include "modules/ModulesExport.h" |
| 9 #include "platform/blob/BlobData.h" | 9 #include "platform/blob/BlobData.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "platform/network/EncodedFormData.h" | 11 #include "platform/network/EncodedFormData.h" |
| 12 #include "wtf/PassRefPtr.h" | 12 #include "wtf/PassRefPtr.h" |
| 13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class ExecutionContext; |
| 18 |
| 17 // BytesConsumer represents the "consumer" side of a data pipe. A user | 19 // BytesConsumer represents the "consumer" side of a data pipe. A user |
| 18 // can read data from it. | 20 // can read data from it. |
| 19 // | 21 // |
| 20 // A BytesConsumer is bound to the thread on which it is created. | 22 // A BytesConsumer is bound to the thread on which it is created. |
| 21 // BytesConsumer has four states: waiting, readable, closed and errored. Once | 23 // BytesConsumer has four states: waiting, readable, closed and errored. Once |
| 22 // the state becomes closed or errored, it will never change. |readable| means | 24 // the state becomes closed or errored, it will never change. |readable| means |
| 23 // that the BytesConsumer is ready to read non-empty bytes synchronously. | 25 // that the BytesConsumer is ready to read non-empty bytes synchronously. |
| 24 class MODULES_EXPORT BytesConsumer : public GarbageCollectedFinalized<BytesConsu
mer> { | 26 class MODULES_EXPORT BytesConsumer : public GarbageCollectedFinalized<BytesConsu
mer> { |
| 25 public: | 27 public: |
| 26 enum class Result { | 28 enum class Result { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 virtual PublicState getPublicState() const = 0; | 134 virtual PublicState getPublicState() const = 0; |
| 133 | 135 |
| 134 // Returns the associated error of this object. This function can be called | 136 // Returns the associated error of this object. This function can be called |
| 135 // only when errored. | 137 // only when errored. |
| 136 virtual Error getError() const = 0; | 138 virtual Error getError() const = 0; |
| 137 | 139 |
| 138 // Each implementation should return a string that represents the | 140 // Each implementation should return a string that represents the |
| 139 // implementation for debug purpose. | 141 // implementation for debug purpose. |
| 140 virtual String debugName() const = 0; | 142 virtual String debugName() const = 0; |
| 141 | 143 |
| 144 // Creates two BytesConsumer both of which represent the data sequence that |
| 145 // would be read from |src| and store them to |*dest1| and |*dest2|. |
| 146 // |src| must not have a client when called. |
| 147 static void tee(ExecutionContext*, BytesConsumer* src, BytesConsumer** dest1
, BytesConsumer** dest2); |
| 148 |
| 142 DEFINE_INLINE_VIRTUAL_TRACE() {} | 149 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 143 | 150 |
| 144 protected: | 151 protected: |
| 145 // This InternalState directly corresponds to the states in the class | 152 // This InternalState directly corresponds to the states in the class |
| 146 // comments. This enum is defined here for subclasses. | 153 // comments. This enum is defined here for subclasses. |
| 147 enum class InternalState { | 154 enum class InternalState { |
| 148 Readable, | 155 Readable, |
| 149 Waiting, | 156 Waiting, |
| 150 Closed, | 157 Closed, |
| 151 Errored, | 158 Errored, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 163 return PublicState::Errored; | 170 return PublicState::Errored; |
| 164 } | 171 } |
| 165 NOTREACHED(); | 172 NOTREACHED(); |
| 166 return PublicState::ReadableOrWaiting; | 173 return PublicState::ReadableOrWaiting; |
| 167 } | 174 } |
| 168 }; | 175 }; |
| 169 | 176 |
| 170 } // namespace blink | 177 } // namespace blink |
| 171 | 178 |
| 172 #endif // BytesConsumer_h | 179 #endif // BytesConsumer_h |
| OLD | NEW |