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" |
11 #include "content/browser/byte_stream.h" | 11 #include "content/browser/byte_stream.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class HttpResponseHeaders; | |
17 class IOBuffer; | 16 class IOBuffer; |
18 } | 17 } |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 | 20 |
22 class StreamHandle; | 21 class StreamHandle; |
23 class StreamHandleImpl; | 22 class StreamHandleImpl; |
24 class StreamReadObserver; | 23 class StreamReadObserver; |
25 class StreamRegistry; | 24 class StreamRegistry; |
26 class StreamWriteObserver; | 25 class StreamWriteObserver; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 70 |
72 // Notifies this stream that it will not be receiving any more data. | 71 // Notifies this stream that it will not be receiving any more data. |
73 void Finalize(); | 72 void Finalize(); |
74 | 73 |
75 // Reads a maximum of |buf_size| from the stream into |buf|. Sets | 74 // Reads a maximum of |buf_size| from the stream into |buf|. Sets |
76 // |*bytes_read| to the number of bytes actually read. | 75 // |*bytes_read| to the number of bytes actually read. |
77 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, | 76 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, |
78 // and STREAM_COMPLETE if the stream is finalized and all data has been read. | 77 // and STREAM_COMPLETE if the stream is finalized and all data has been read. |
79 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 78 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
80 | 79 |
81 scoped_ptr<StreamHandle> CreateHandle( | 80 scoped_ptr<StreamHandle> CreateHandle(); |
82 const GURL& original_url, | |
83 const std::string& mime_type, | |
84 scoped_refptr<net::HttpResponseHeaders> response_headers); | |
85 void CloseHandle(); | 81 void CloseHandle(); |
86 | 82 |
87 // Indicates whether there is space in the buffer to add more data. | 83 // Indicates whether there is space in the buffer to add more data. |
88 bool can_add_data() const { return can_add_data_; } | 84 bool can_add_data() const { return can_add_data_; } |
89 | 85 |
90 const GURL& url() const { return url_; } | 86 const GURL& url() const { return url_; } |
91 | 87 |
92 // For StreamRegistry to remember the last memory usage reported to it. | 88 // For StreamRegistry to remember the last memory usage reported to it. |
93 size_t last_total_buffered_bytes() const { | 89 size_t last_total_buffered_bytes() const { |
94 return last_total_buffered_bytes_; | 90 return last_total_buffered_bytes_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 127 |
132 StreamHandleImpl* stream_handle_; | 128 StreamHandleImpl* stream_handle_; |
133 | 129 |
134 base::WeakPtrFactory<Stream> weak_ptr_factory_; | 130 base::WeakPtrFactory<Stream> weak_ptr_factory_; |
135 DISALLOW_COPY_AND_ASSIGN(Stream); | 131 DISALLOW_COPY_AND_ASSIGN(Stream); |
136 }; | 132 }; |
137 | 133 |
138 } // namespace content | 134 } // namespace content |
139 | 135 |
140 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ | 136 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ |
OLD | NEW |