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_DOWNLOAD_BYTE_STREAM_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_BYTE_STREAM_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_BYTE_STREAM_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_BYTE_STREAM_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <deque> | 10 #include <deque> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "content/public/browser/download_interrupt_reasons.h" | 15 #include "content/public/browser/download_interrupt_reasons.h" |
16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
20 } | 20 } |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
24 // TODO(zork): Move this class out of content/browser/download | |
25 // crbug.com/180833 | |
26 // | |
27 // A byte stream is a pipe to transfer bytes between a source and a | 24 // A byte stream is a pipe to transfer bytes between a source and a |
28 // sink, which may be on different threads. It is intended to be the | 25 // sink, which may be on different threads. It is intended to be the |
29 // only connection between source and sink; they need have no | 26 // only connection between source and sink; they need have no |
30 // direct awareness of each other aside from the byte stream. The source and | 27 // direct awareness of each other aside from the byte stream. The source and |
31 // the sink have different interfaces to a byte stream, |ByteStreamWriter| | 28 // the sink have different interfaces to a byte stream, |ByteStreamWriter| |
32 // and |ByteStreamReader|. A pair of connected interfaces is generated by | 29 // and |ByteStreamReader|. A pair of connected interfaces is generated by |
33 // calling |CreateByteStream|. | 30 // calling |CreateByteStream|. |
34 // | 31 // |
35 // The source adds bytes to the bytestream via |ByteStreamWriter::Write| | 32 // The source adds bytes to the bytestream via |ByteStreamWriter::Write| |
36 // and the sink retrieves bytes already written via |ByteStreamReader::Read|. | 33 // and the sink retrieves bytes already written via |ByteStreamReader::Read|. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 CONTENT_EXPORT void CreateByteStream( | 187 CONTENT_EXPORT void CreateByteStream( |
191 scoped_refptr<base::SequencedTaskRunner> input_task_runner, | 188 scoped_refptr<base::SequencedTaskRunner> input_task_runner, |
192 scoped_refptr<base::SequencedTaskRunner> output_task_runner, | 189 scoped_refptr<base::SequencedTaskRunner> output_task_runner, |
193 size_t buffer_size, | 190 size_t buffer_size, |
194 scoped_ptr<ByteStreamWriter>* input, | 191 scoped_ptr<ByteStreamWriter>* input, |
195 scoped_ptr<ByteStreamReader>* output); | 192 scoped_ptr<ByteStreamReader>* output); |
196 | 193 |
197 } // namespace content | 194 } // namespace content |
198 | 195 |
199 #endif // CONTENT_BROWSER_DOWNLOAD_BYTE_STREAM_H_ | 196 #endif // CONTENT_BROWSER_DOWNLOAD_BYTE_STREAM_H_ |
OLD | NEW |