OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_STREAMS_STREAM_H_ | 5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_H_ |
6 #define CONTENT_BROWSER_STREAMS_STREAM_H_ | 6 #define CONTENT_BROWSER_STREAMS_STREAM_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // Stops accepting new data, clears all buffer, unregisters this stream from | 61 // Stops accepting new data, clears all buffer, unregisters this stream from |
62 // |registry_| and make coming ReadRawData() calls return STREAM_ABORTED. | 62 // |registry_| and make coming ReadRawData() calls return STREAM_ABORTED. |
63 void Abort(); | 63 void Abort(); |
64 | 64 |
65 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. | 65 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. |
66 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); | 66 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); |
67 // Adds data of |size| at |data| to the stream. This method creates a copy | 67 // Adds data of |size| at |data| to the stream. This method creates a copy |
68 // of the data, and then passes it to |writer_|. | 68 // of the data, and then passes it to |writer_|. |
69 void AddData(const char* data, size_t size); | 69 void AddData(const char* data, size_t size); |
70 | 70 |
| 71 // Flushes contents buffered in the stream to the corresponding reader. |
| 72 void Flush(); |
| 73 |
71 // Notifies this stream that it will not be receiving any more data. | 74 // Notifies this stream that it will not be receiving any more data. |
72 void Finalize(); | 75 void Finalize(); |
73 | 76 |
74 // Reads a maximum of |buf_size| from the stream into |buf|. Sets | 77 // Reads a maximum of |buf_size| from the stream into |buf|. Sets |
75 // |*bytes_read| to the number of bytes actually read. | 78 // |*bytes_read| to the number of bytes actually read. |
76 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, | 79 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, |
77 // and STREAM_COMPLETE if the stream is finalized and all data has been read. | 80 // and STREAM_COMPLETE if the stream is finalized and all data has been read. |
78 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 81 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
79 | 82 |
80 scoped_ptr<StreamHandle> CreateHandle(); | 83 scoped_ptr<StreamHandle> CreateHandle(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 130 |
128 StreamHandleImpl* stream_handle_; | 131 StreamHandleImpl* stream_handle_; |
129 | 132 |
130 base::WeakPtrFactory<Stream> weak_ptr_factory_; | 133 base::WeakPtrFactory<Stream> weak_ptr_factory_; |
131 DISALLOW_COPY_AND_ASSIGN(Stream); | 134 DISALLOW_COPY_AND_ASSIGN(Stream); |
132 }; | 135 }; |
133 | 136 |
134 } // namespace content | 137 } // namespace content |
135 | 138 |
136 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ | 139 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ |
OLD | NEW |