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

Side by Side Diff: net/quic/chromium/quic_http_stream.h

Issue 2777333002: Simplify the the logic for setting the final response status for a (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « no previous file | net/quic/chromium/quic_http_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ 5 #ifndef NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_
6 #define NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ 6 #define NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 int DoSendBody(); 128 int DoSendBody();
129 int DoSendBodyComplete(int rv); 129 int DoSendBodyComplete(int rv);
130 130
131 int ProcessResponseHeaders(const SpdyHeaderBlock& headers); 131 int ProcessResponseHeaders(const SpdyHeaderBlock& headers);
132 132
133 int ReadAvailableData(IOBuffer* buf, int buf_len); 133 int ReadAvailableData(IOBuffer* buf, int buf_len);
134 void EnterStateSendHeaders(); 134 void EnterStateSendHeaders();
135 135
136 void ResetStream(); 136 void ResetStream();
137 137
138 // If |has_response_status_| is false, sets |response_status| to the result
139 // of ComputeResponseStatus(). Returns |response_status_|.
140 int GetResponseStatus();
141 // Sets the result of |ComputeResponseStatus()| as the |response_status_|.
142 void SaveResponseStatus();
143 // Sets |response_status_| to |response_status| and sets
144 // |has_response_status_| to true.
145 void SetResponseStatus(int response_status);
146 // Computes the correct response status based on the status of the handshake,
147 // |session_error|, |connection_error| and |stream_error|.
148 int ComputeResponseStatus() const;
149
138 State next_state_; 150 State next_state_;
139 151
140 base::WeakPtr<QuicChromiumClientSession> session_; 152 base::WeakPtr<QuicChromiumClientSession> session_;
141 153
142 HttpServerProperties* http_server_properties_; 154 HttpServerProperties* http_server_properties_;
143 155
144 QuicVersion quic_version_; 156 QuicVersion quic_version_;
145 int session_error_; // Error code from the connection shutdown. 157 int session_error_; // Error code from the connection shutdown.
146 bool was_handshake_confirmed_; // True if the crypto handshake succeeded. 158 bool was_handshake_confirmed_; // True if the crypto handshake succeeded.
147 QuicChromiumClientSession::StreamRequest stream_request_; 159 QuicChromiumClientSession::StreamRequest stream_request_;
148 QuicChromiumClientStream* stream_; // Non-owning. 160 QuicChromiumClientStream* stream_; // Non-owning.
149 161
150 // The following three fields are all owned by the caller and must 162 // The following three fields are all owned by the caller and must
151 // outlive this object, according to the HttpStream contract. 163 // outlive this object, according to the HttpStream contract.
152 164
153 // The request to send. 165 // The request to send.
154 // Only valid before the response body is read. 166 // Only valid before the response body is read.
155 const HttpRequestInfo* request_info_; 167 const HttpRequestInfo* request_info_;
156 168
157 // The request body to send, if any, owned by the caller. 169 // The request body to send, if any, owned by the caller.
158 UploadDataStream* request_body_stream_; 170 UploadDataStream* request_body_stream_;
159 // Time the request was issued. 171 // Time the request was issued.
160 base::Time request_time_; 172 base::Time request_time_;
161 // The priority of the request. 173 // The priority of the request.
162 RequestPriority priority_; 174 RequestPriority priority_;
163 // |response_info_| is the HTTP response data object which is filled in 175 // |response_info_| is the HTTP response data object which is filled in
164 // when a the response headers are read. It is not owned by this stream. 176 // when a the response headers are read. It is not owned by this stream.
165 HttpResponseInfo* response_info_; 177 HttpResponseInfo* response_info_;
178 bool has_response_status_; // true if response_status_ as been set.
166 // Because response data is buffered, also buffer the response status if the 179 // Because response data is buffered, also buffer the response status if the
167 // stream is explicitly closed via OnError or OnClose with an error. 180 // stream is explicitly closed via OnError or OnClose with an error.
168 // Once all buffered data has been returned, this will be used as the final 181 // Once all buffered data has been returned, this will be used as the final
169 // response. 182 // response.
170 int response_status_; 183 int response_status_;
171 184
172 // Serialized request headers. 185 // Serialized request headers.
173 SpdyHeaderBlock request_headers_; 186 SpdyHeaderBlock request_headers_;
174 187
175 bool response_headers_received_; 188 bool response_headers_received_;
(...skipping 19 matching lines...) Expand all
195 scoped_refptr<IOBuffer> user_buffer_; 208 scoped_refptr<IOBuffer> user_buffer_;
196 int user_buffer_len_; 209 int user_buffer_len_;
197 210
198 // Temporary buffer used to read the request body from UploadDataStream. 211 // Temporary buffer used to read the request body from UploadDataStream.
199 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; 212 scoped_refptr<IOBufferWithSize> raw_request_body_buf_;
200 // Wraps raw_request_body_buf_ to read the remaining data progressively. 213 // Wraps raw_request_body_buf_ to read the remaining data progressively.
201 scoped_refptr<DrainableIOBuffer> request_body_buf_; 214 scoped_refptr<DrainableIOBuffer> request_body_buf_;
202 215
203 NetLogWithSource stream_net_log_; 216 NetLogWithSource stream_net_log_;
204 217
205 QuicErrorCode quic_connection_error_; 218 QuicErrorCode quic_connection_error_; // Cached connection error code.
219 QuicRstStreamErrorCode quic_stream_error_; // Cached stream error code.
206 220
207 // True when this stream receives a go away from server due to port migration. 221 // True when this stream receives a go away from server due to port migration.
208 bool port_migration_detected_; 222 bool port_migration_detected_;
209 223
210 bool found_promise_; 224 bool found_promise_;
211 // |QuicClientPromisedInfo| owns this. It will be set when |Try()| 225 // |QuicClientPromisedInfo| owns this. It will be set when |Try()|
212 // is asynchronous, i.e. it returned QUIC_PENDING, and remains valid 226 // is asynchronous, i.e. it returned QUIC_PENDING, and remains valid
213 // until |OnRendezvouResult()| fires or |push_handle_->Cancel()| is 227 // until |OnRendezvouResult()| fires or |push_handle_->Cancel()| is
214 // invoked. 228 // invoked.
215 QuicClientPushPromiseIndex::TryHandle* push_handle_; 229 QuicClientPushPromiseIndex::TryHandle* push_handle_;
216 230
217 // Set to true when DoLoop() is being executed, false otherwise. 231 // Set to true when DoLoop() is being executed, false otherwise.
218 bool in_loop_; 232 bool in_loop_;
219 233
220 // Session connect timing info. 234 // Session connect timing info.
221 LoadTimingInfo::ConnectTiming connect_timing_; 235 LoadTimingInfo::ConnectTiming connect_timing_;
222 236
223 base::WeakPtrFactory<QuicHttpStream> weak_factory_; 237 base::WeakPtrFactory<QuicHttpStream> weak_factory_;
224 238
225 DISALLOW_COPY_AND_ASSIGN(QuicHttpStream); 239 DISALLOW_COPY_AND_ASSIGN(QuicHttpStream);
226 }; 240 };
227 241
228 } // namespace net 242 } // namespace net
229 243
230 #endif // NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ 244 #endif // NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/chromium/quic_http_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698