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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 bool SetReadObserver(StreamReadObserver* observer); | 52 bool SetReadObserver(StreamReadObserver* observer); |
53 | 53 |
54 // Removes the read observer. |observer| must be the current observer. | 54 // Removes the read observer. |observer| must be the current observer. |
55 void RemoveReadObserver(StreamReadObserver* observer); | 55 void RemoveReadObserver(StreamReadObserver* observer); |
56 | 56 |
57 // Removes the write observer. |observer| must be the current observer. | 57 // Removes the write observer. |observer| must be the current observer. |
58 void RemoveWriteObserver(StreamWriteObserver* observer); | 58 void RemoveWriteObserver(StreamWriteObserver* observer); |
59 | 59 |
60 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. | 60 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. |
61 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); | 61 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); |
| 62 // Adds data of |size| at |data| to the stream. This method creates a copy |
| 63 // of the data, and then passes it to |writer_|. |
| 64 void AddData(const char* data, size_t size); |
62 | 65 |
63 // Notifies this stream that it will not be receiving any more data. | 66 // Notifies this stream that it will not be receiving any more data. |
64 void Finalize(); | 67 void Finalize(); |
65 | 68 |
66 // Reads a maximum of |buf_size| from the stream into |buf|. Sets | 69 // Reads a maximum of |buf_size| from the stream into |buf|. Sets |
67 // |*bytes_read| to the number of bytes actually read. | 70 // |*bytes_read| to the number of bytes actually read. |
68 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, | 71 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, |
69 // and STREAM_COMPLETE if the stream is finalized and all data has been read. | 72 // and STREAM_COMPLETE if the stream is finalized and all data has been read. |
70 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 73 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
71 | 74 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 106 |
104 StreamHandleImpl* stream_handle_; | 107 StreamHandleImpl* stream_handle_; |
105 | 108 |
106 base::WeakPtrFactory<Stream> weak_ptr_factory_; | 109 base::WeakPtrFactory<Stream> weak_ptr_factory_; |
107 DISALLOW_COPY_AND_ASSIGN(Stream); | 110 DISALLOW_COPY_AND_ASSIGN(Stream); |
108 }; | 111 }; |
109 | 112 |
110 } // namespace content | 113 } // namespace content |
111 | 114 |
112 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ | 115 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ |
OLD | NEW |