OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_BYTE_STREAM_H_ | 5 #ifndef CONTENT_BROWSER_BYTE_STREAM_H_ |
6 #define CONTENT_BROWSER_BYTE_STREAM_H_ | 6 #define CONTENT_BROWSER_BYTE_STREAM_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 static const int kFractionBufferBeforeSending; | 127 static const int kFractionBufferBeforeSending; |
128 | 128 |
129 virtual ~ByteStreamWriter() = 0; | 129 virtual ~ByteStreamWriter() = 0; |
130 | 130 |
131 // Always adds the data passed into the ByteStream. Returns true | 131 // Always adds the data passed into the ByteStream. Returns true |
132 // if more data may be added without exceeding the class limit | 132 // if more data may be added without exceeding the class limit |
133 // on data. Takes ownership of |buffer|. | 133 // on data. Takes ownership of |buffer|. |
134 virtual bool Write(scoped_refptr<net::IOBuffer> buffer, | 134 virtual bool Write(scoped_refptr<net::IOBuffer> buffer, |
135 size_t byte_count) = 0; | 135 size_t byte_count) = 0; |
136 | 136 |
| 137 // Flushes contents buffered in this writer to the corresponding reader |
| 138 // regardless if buffer filling rate is greater than |
| 139 // kFractionBufferBeforeSending or not. Does nothing if there's no contents |
| 140 // buffered. |
| 141 virtual void Flush() = 0; |
| 142 |
137 // Signal that all data that is going to be sent, has been sent, | 143 // Signal that all data that is going to be sent, has been sent, |
138 // and provide a status. |DOWNLOAD_INTERRUPT_REASON_NONE| should be | 144 // and provide a status. |DOWNLOAD_INTERRUPT_REASON_NONE| should be |
139 // passed for successful completion. | 145 // passed for successful completion. |
140 virtual void Close(DownloadInterruptReason status) = 0; | 146 virtual void Close(DownloadInterruptReason status) = 0; |
141 | 147 |
142 // Register a callback to be called when the stream transitions from | 148 // Register a callback to be called when the stream transitions from |
143 // full to having space available. The callback will always be | 149 // full to having space available. The callback will always be |
144 // called on the task runner associated with the ByteStreamWriter. | 150 // called on the task runner associated with the ByteStreamWriter. |
145 // This callback will only be called if a call to Write has previously | 151 // This callback will only be called if a call to Write has previously |
146 // returned false (i.e. the ByteStream has been filled). | 152 // returned false (i.e. the ByteStream has been filled). |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 CONTENT_EXPORT void CreateByteStream( | 193 CONTENT_EXPORT void CreateByteStream( |
188 scoped_refptr<base::SequencedTaskRunner> input_task_runner, | 194 scoped_refptr<base::SequencedTaskRunner> input_task_runner, |
189 scoped_refptr<base::SequencedTaskRunner> output_task_runner, | 195 scoped_refptr<base::SequencedTaskRunner> output_task_runner, |
190 size_t buffer_size, | 196 size_t buffer_size, |
191 scoped_ptr<ByteStreamWriter>* input, | 197 scoped_ptr<ByteStreamWriter>* input, |
192 scoped_ptr<ByteStreamReader>* output); | 198 scoped_ptr<ByteStreamReader>* output); |
193 | 199 |
194 } // namespace content | 200 } // namespace content |
195 | 201 |
196 #endif // CONTENT_BROWSER_BYTE_STREAM_H_ | 202 #endif // CONTENT_BROWSER_BYTE_STREAM_H_ |
OLD | NEW |