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

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

Issue 2873963003: Add an async ReadInitialHeaders method to QuicChromiumClientStream::Handle (Closed)
Patch Set: Rebase Created 3 years, 7 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 | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_http_stream_test.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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 return rv > 0 ? OK : rv; 307 return rv > 0 ? OK : rv;
308 } 308 }
309 309
310 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) { 310 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) {
311 CHECK(callback_.is_null()); 311 CHECK(callback_.is_null());
312 CHECK(!callback.is_null()); 312 CHECK(!callback.is_null());
313 313
314 if (stream_ == nullptr) 314 if (stream_ == nullptr)
315 return GetResponseStatus(); 315 return GetResponseStatus();
316
317 int rv = stream_->ReadInitialHeaders(
318 &response_header_block_,
319 base::Bind(&QuicHttpStream::OnReadResponseHeadersComplete,
320 weak_factory_.GetWeakPtr()));
321
322 if (rv == ERR_IO_PENDING) {
323 // Still waiting for the response, return IO_PENDING.
324 CHECK(callback_.is_null());
325 callback_ = callback;
326 return ERR_IO_PENDING;
327 }
328
329 if (rv < 0)
330 return rv;
331
316 // Check if we already have the response headers. If so, return synchronously. 332 // Check if we already have the response headers. If so, return synchronously.
317 if (response_headers_received_) 333 if (response_headers_received_)
318 return OK; 334 return OK;
319 335
320 // Still waiting for the response, return IO_PENDING. 336 headers_bytes_received_ += rv;
321 CHECK(callback_.is_null()); 337 return ProcessResponseHeaders(response_header_block_);
322 callback_ = callback;
323 return ERR_IO_PENDING;
324 } 338 }
325 339
326 int QuicHttpStream::ReadResponseBody(IOBuffer* buf, 340 int QuicHttpStream::ReadResponseBody(IOBuffer* buf,
327 int buf_len, 341 int buf_len,
328 const CompletionCallback& callback) { 342 const CompletionCallback& callback) {
329 CHECK(callback_.is_null()); 343 CHECK(callback_.is_null());
330 CHECK(!callback.is_null()); 344 CHECK(!callback.is_null());
331 CHECK(!user_buffer_.get()); 345 CHECK(!user_buffer_.get());
332 CHECK_EQ(0, user_buffer_len_); 346 CHECK_EQ(0, user_buffer_len_);
333 347
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 ConnectionInfoFromQuicVersion(quic_session()->GetQuicVersion()); 439 ConnectionInfoFromQuicVersion(quic_session()->GetQuicVersion());
426 quic_session()->PopulateNetErrorDetails(details); 440 quic_session()->PopulateNetErrorDetails(details);
427 if (quic_session()->IsCryptoHandshakeConfirmed()) 441 if (quic_session()->IsCryptoHandshakeConfirmed())
428 details->quic_connection_error = quic_connection_error_; 442 details->quic_connection_error = quic_connection_error_;
429 } 443 }
430 444
431 void QuicHttpStream::SetPriority(RequestPriority priority) { 445 void QuicHttpStream::SetPriority(RequestPriority priority) {
432 priority_ = priority; 446 priority_ = priority;
433 } 447 }
434 448
435 void QuicHttpStream::OnInitialHeadersAvailable(const SpdyHeaderBlock& headers, 449 void QuicHttpStream::OnReadResponseHeadersComplete(int rv) {
436 size_t frame_len) { 450 DCHECK(callback_);
437 DCHECK(!response_headers_received_); 451 DCHECK(!response_headers_received_);
438 headers_bytes_received_ += frame_len; 452 if (rv > 0) {
439 453 headers_bytes_received_ += rv;
440 int rv = ProcessResponseHeaders(headers); 454 rv = ProcessResponseHeaders(response_header_block_);
455 }
441 if (rv != ERR_IO_PENDING && !callback_.is_null()) { 456 if (rv != ERR_IO_PENDING && !callback_.is_null()) {
442 DoCallback(rv); 457 DoCallback(rv);
443 } 458 }
444 } 459 }
445 460
446 void QuicHttpStream::OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, 461 void QuicHttpStream::OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers,
447 size_t frame_len) { 462 size_t frame_len) {
448 DCHECK(response_headers_received_); 463 DCHECK(response_headers_received_);
449 headers_bytes_received_ += frame_len; 464 headers_bytes_received_ += frame_len;
450 465
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) { 845 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) {
831 return ERR_QUIC_PROTOCOL_ERROR; 846 return ERR_QUIC_PROTOCOL_ERROR;
832 } 847 }
833 848
834 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_); 849 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_);
835 850
836 return ERR_QUIC_PROTOCOL_ERROR; 851 return ERR_QUIC_PROTOCOL_ERROR;
837 } 852 }
838 853
839 } // namespace net 854 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698