Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1355)

Side by Side Diff: content/browser/streams/stream.h

Issue 2368913002: Fix stream errors that occur after a stream starts not propagating. (Closed)
Patch Set: review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Returns the status of the stream. This is either an error code that
89 // occurred while reading, or the status that was set in Finalize above.
90 int GetStatus();
91
88 // Indicates whether there is space in the buffer to add more data. 92 // Indicates whether there is space in the buffer to add more data.
89 bool can_add_data() const { return can_add_data_; } 93 bool can_add_data() const { return can_add_data_; }
90 94
91 const GURL& url() const { return url_; } 95 const GURL& url() const { return url_; }
92 96
93 // For StreamRegistry to remember the last memory usage reported to it. 97 // For StreamRegistry to remember the last memory usage reported to it.
94 size_t last_total_buffered_bytes() const { 98 size_t last_total_buffered_bytes() const {
95 return last_total_buffered_bytes_; 99 return last_total_buffered_bytes_;
96 } 100 }
97 101
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 136
133 StreamHandleImpl* stream_handle_; 137 StreamHandleImpl* stream_handle_;
134 138
135 base::WeakPtrFactory<Stream> weak_ptr_factory_; 139 base::WeakPtrFactory<Stream> weak_ptr_factory_;
136 DISALLOW_COPY_AND_ASSIGN(Stream); 140 DISALLOW_COPY_AND_ASSIGN(Stream);
137 }; 141 };
138 142
139 } // namespace content 143 } // namespace content
140 144
141 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ 145 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_url_request_job_unittest.cc ('k') | content/browser/streams/stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698