| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. | 67 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. |
| 68 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); | 68 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); |
| 69 // Adds data of |size| at |data| to the stream. This method creates a copy | 69 // Adds data of |size| at |data| to the stream. This method creates a copy |
| 70 // of the data, and then passes it to |writer_|. | 70 // of the data, and then passes it to |writer_|. |
| 71 void AddData(const char* data, size_t size); | 71 void AddData(const char* data, size_t size); |
| 72 | 72 |
| 73 // Flushes contents buffered in the stream to the corresponding reader. | 73 // Flushes contents buffered in the stream to the corresponding reader. |
| 74 void Flush(); | 74 void Flush(); |
| 75 | 75 |
| 76 // Notifies this stream that it will not be receiving any more data. | 76 // Notifies this stream that it will not be receiving any more data. |
| 77 void Finalize(); | 77 void Finalize(int status); |
| 78 | 78 |
| 79 // Reads a maximum of |buf_size| from the stream into |buf|. Sets | 79 // Reads a maximum of |buf_size| from the stream into |buf|. Sets |
| 80 // |*bytes_read| to the number of bytes actually read. | 80 // |*bytes_read| to the number of bytes actually read. |
| 81 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, | 81 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, |
| 82 // and STREAM_COMPLETE if the stream is finalized and all data has been read. | 82 // and STREAM_COMPLETE if the stream is finalized and all data has been read. |
| 83 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 83 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
| 84 | 84 |
| 85 std::unique_ptr<StreamHandle> CreateHandle(); | 85 std::unique_ptr<StreamHandle> CreateHandle(); |
| 86 void CloseHandle(); | 86 void CloseHandle(); |
| 87 | 87 |
| 88 int GetStatus(); |
| 89 |
| 88 // Indicates whether there is space in the buffer to add more data. | 90 // Indicates whether there is space in the buffer to add more data. |
| 89 bool can_add_data() const { return can_add_data_; } | 91 bool can_add_data() const { return can_add_data_; } |
| 90 | 92 |
| 91 const GURL& url() const { return url_; } | 93 const GURL& url() const { return url_; } |
| 92 | 94 |
| 93 // For StreamRegistry to remember the last memory usage reported to it. | 95 // For StreamRegistry to remember the last memory usage reported to it. |
| 94 size_t last_total_buffered_bytes() const { | 96 size_t last_total_buffered_bytes() const { |
| 95 return last_total_buffered_bytes_; | 97 return last_total_buffered_bytes_; |
| 96 } | 98 } |
| 97 | 99 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 134 |
| 133 StreamHandleImpl* stream_handle_; | 135 StreamHandleImpl* stream_handle_; |
| 134 | 136 |
| 135 base::WeakPtrFactory<Stream> weak_ptr_factory_; | 137 base::WeakPtrFactory<Stream> weak_ptr_factory_; |
| 136 DISALLOW_COPY_AND_ASSIGN(Stream); | 138 DISALLOW_COPY_AND_ASSIGN(Stream); |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 } // namespace content | 141 } // namespace content |
| 140 | 142 |
| 141 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ | 143 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ |
| OLD | NEW |