| 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/Compiler.h" |
| 12 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
| 13 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class ExecutionContext; | 18 class ExecutionContext; |
| 18 | 19 |
| 19 // BytesConsumer represents the "consumer" side of a data pipe. A user | 20 // BytesConsumer represents the "consumer" side of a data pipe. A user |
| 20 // can read data from it. | 21 // can read data from it. |
| 21 // | 22 // |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 76 |
| 76 // Reads data into |buffer| up to |size| bytes. The actual read size will | 77 // Reads data into |buffer| up to |size| bytes. The actual read size will |
| 77 // be stored in |*readSize|. This function cannot be called when a two-phase | 78 // be stored in |*readSize|. This function cannot be called when a two-phase |
| 78 // read is in progress. | 79 // read is in progress. |
| 79 // Returns Ok when readable. | 80 // Returns Ok when readable. |
| 80 // Returns ShouldWait when it's waiting. | 81 // Returns ShouldWait when it's waiting. |
| 81 // Returns Done when closed. | 82 // Returns Done when closed. |
| 82 // Returns Error when errored. | 83 // Returns Error when errored. |
| 83 // |buffer| can be null if |size| is 0. | 84 // |buffer| can be null if |size| is 0. |
| 84 // |*readSize| will be set to 0 if not readable. | 85 // |*readSize| will be set to 0 if not readable. |
| 85 virtual Result read(char* buffer, size_t /* size */, size_t* readSize); | 86 virtual Result read(char* buffer, size_t /* size */, size_t* readSize) WARN_
UNUSED_RESULT; |
| 86 | 87 |
| 87 // Begins a two-phase read. On success, the function stores a buffer | 88 // Begins a two-phase read. On success, the function stores a buffer |
| 88 // that contains the read data of length |*available| into |*buffer|. | 89 // that contains the read data of length |*available| into |*buffer|. |
| 89 // Returns Ok when readable. | 90 // Returns Ok when readable. |
| 90 // Returns ShouldWait when it's waiting. | 91 // Returns ShouldWait when it's waiting. |
| 91 // Returns Done when it's closed. | 92 // Returns Done when it's closed. |
| 92 // Returns Error when errored. | 93 // Returns Error when errored. |
| 93 // When not readable, the caller don't have to (and must not) call | 94 // When not readable, the caller don't have to (and must not) call |
| 94 // endRead, because the read session implicitly ends in that case. | 95 // endRead, because the read session implicitly ends in that case. |
| 95 // | 96 // |
| 96 // |*buffer| will become invalid when this object becomes unreachable, | 97 // |*buffer| will become invalid when this object becomes unreachable, |
| 97 // even if endRead is not called. | 98 // even if endRead is not called. |
| 98 // | 99 // |
| 99 // |*buffer| will be set to null and |*available| will be set to 0 if not | 100 // |*buffer| will be set to null and |*available| will be set to 0 if not |
| 100 // readable. | 101 // readable. |
| 101 virtual Result beginRead(const char** buffer, size_t* available) = 0; | 102 virtual Result beginRead(const char** buffer, size_t* available) WARN_UNUSED
_RESULT = 0; |
| 102 | 103 |
| 103 // Ends a two-phase read. | 104 // Ends a two-phase read. |
| 104 virtual Result endRead(size_t readSize) = 0; | 105 virtual Result endRead(size_t readSize) WARN_UNUSED_RESULT = 0; |
| 105 | 106 |
| 106 // Drains the data as a BlobDataHandle. | 107 // Drains the data as a BlobDataHandle. |
| 107 // When this function returns a non-null value, the returned blob handle | 108 // When this function returns a non-null value, the returned blob handle |
| 108 // contains bytes that would be read through read, beginRead and | 109 // contains bytes that would be read through read, beginRead and |
| 109 // endRead functions without calling this function. In such a case, this | 110 // endRead functions without calling this function. In such a case, this |
| 110 // object becomes closed. | 111 // object becomes closed. |
| 111 // When this function returns null value, this function does nothing. | 112 // When this function returns null value, this function does nothing. |
| 112 // When |policy| is DisallowBlobWithInvalidSize, this function doesn't | 113 // When |policy| is DisallowBlobWithInvalidSize, this function doesn't |
| 113 // return a non-null blob handle with unspecified size. | 114 // return a non-null blob handle with unspecified size. |
| 114 // The type of the returned blob handle may not be meaningful. | 115 // The type of the returned blob handle may not be meaningful. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return PublicState::Errored; | 178 return PublicState::Errored; |
| 178 } | 179 } |
| 179 NOTREACHED(); | 180 NOTREACHED(); |
| 180 return PublicState::ReadableOrWaiting; | 181 return PublicState::ReadableOrWaiting; |
| 181 } | 182 } |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 } // namespace blink | 185 } // namespace blink |
| 185 | 186 |
| 186 #endif // BytesConsumer_h | 187 #endif // BytesConsumer_h |
| OLD | NEW |