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

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

Issue 2804723003: QUIC - fix crash bug in client handling of Server Push. (Closed)
Patch Set: review feedback + pull 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_network_transaction_unittest.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 #include "net/quic/chromium/quic_http_stream.h" 5 #include "net/quic/chromium/quic_http_stream.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Store the serialized request headers. 267 // Store the serialized request headers.
268 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, 268 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers,
269 /*direct=*/true, &request_headers_); 269 /*direct=*/true, &request_headers_);
270 270
271 // Store the request body. 271 // Store the request body.
272 request_body_stream_ = request_info_->upload_data_stream; 272 request_body_stream_ = request_info_->upload_data_stream;
273 if (request_body_stream_) { 273 if (request_body_stream_) {
274 // A request with a body is ineligible for push, so reset the 274 // A request with a body is ineligible for push, so reset the
275 // promised stream and request a new stream. 275 // promised stream and request a new stream.
276 if (found_promise_) { 276 if (found_promise_) {
277 found_promise_ = false;
278 std::string url(request_info_->url.spec()); 277 std::string url(request_info_->url.spec());
279 QuicClientPromisedInfo* promised = 278 QuicClientPromisedInfo* promised =
280 session_->push_promise_index()->GetPromised(url); 279 session_->push_promise_index()->GetPromised(url);
281 if (promised != nullptr) { 280 if (promised != nullptr) {
282 session_->ResetPromised(promised->id(), QUIC_STREAM_CANCELLED); 281 session_->ResetPromised(promised->id(), QUIC_STREAM_CANCELLED);
283 } 282 }
284 } 283 }
285 284
286 // TODO(rch): Can we be more precise about when to allocate 285 // TODO(rch): Can we be more precise about when to allocate
287 // raw_request_body_buf_. Removed the following check. DoReadRequestBody() 286 // raw_request_body_buf_. Removed the following check. DoReadRequestBody()
288 // was being called even if we didn't yet allocate raw_request_body_buf_. 287 // was being called even if we didn't yet allocate raw_request_body_buf_.
289 // && (request_body_stream_->size() || 288 // && (request_body_stream_->size() ||
290 // request_body_stream_->is_chunked())) 289 // request_body_stream_->is_chunked()))
291 // Use 10 packets as the body buffer size to give enough space to 290 // Use 10 packets as the body buffer size to give enough space to
292 // help ensure we don't often send out partial packets. 291 // help ensure we don't often send out partial packets.
293 raw_request_body_buf_ = 292 raw_request_body_buf_ =
294 new IOBufferWithSize(static_cast<size_t>(10 * kMaxPacketSize)); 293 new IOBufferWithSize(static_cast<size_t>(10 * kMaxPacketSize));
295 // The request body buffer is empty at first. 294 // The request body buffer is empty at first.
296 request_body_buf_ = new DrainableIOBuffer(raw_request_body_buf_.get(), 0); 295 request_body_buf_ = new DrainableIOBuffer(raw_request_body_buf_.get(), 0);
297 } 296 }
298 297
299 // Store the response info. 298 // Store the response info.
300 response_info_ = response; 299 response_info_ = response;
301 300
302 int rv; 301 int rv;
303 302
304 if (found_promise_) { 303 if (!found_promise_) {
304 next_state_ = STATE_SET_REQUEST_PRIORITY;
305 } else if (!request_body_stream_) {
305 next_state_ = STATE_HANDLE_PROMISE; 306 next_state_ = STATE_HANDLE_PROMISE;
306 } else { 307 } else {
307 next_state_ = STATE_SET_REQUEST_PRIORITY; 308 found_promise_ = false;
309 next_state_ = STATE_REQUEST_STREAM;
308 } 310 }
309 rv = DoLoop(OK); 311 rv = DoLoop(OK);
310 312
311 if (rv == ERR_IO_PENDING) 313 if (rv == ERR_IO_PENDING)
312 callback_ = callback; 314 callback_ = callback;
313 315
314 return rv > 0 ? OK : rv; 316 return rv > 0 ? OK : rv;
315 } 317 }
316 318
317 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) { 319 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) {
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 // If |response_info_| is null then the request has not been sent, so 871 // If |response_info_| is null then the request has not been sent, so
870 // return ERR_CONNECTION_CLOSED to permit HttpNetworkTransaction to 872 // return ERR_CONNECTION_CLOSED to permit HttpNetworkTransaction to
871 // retry the request. 873 // retry the request.
872 if (!response_info_) 874 if (!response_info_)
873 return ERR_CONNECTION_CLOSED; 875 return ERR_CONNECTION_CLOSED;
874 876
875 return ERR_QUIC_PROTOCOL_ERROR; 877 return ERR_QUIC_PROTOCOL_ERROR;
876 } 878 }
877 879
878 } // namespace net 880 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/chromium/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698