| OLD | NEW |
| 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/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } else if (!was_handshake_confirmed_) { | 95 } else if (!was_handshake_confirmed_) { |
| 96 rv = ERR_QUIC_HANDSHAKE_FAILED; | 96 rv = ERR_QUIC_HANDSHAKE_FAILED; |
| 97 } | 97 } |
| 98 | 98 |
| 99 ResetAndReturn(&callback_).Run(rv); | 99 ResetAndReturn(&callback_).Run(rv); |
| 100 } | 100 } |
| 101 | 101 |
| 102 int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers, | 102 int QuicHttpStream::SendRequest(const HttpRequestHeaders& request_headers, |
| 103 HttpResponseInfo* response, | 103 HttpResponseInfo* response, |
| 104 const CompletionCallback& callback) { | 104 const CompletionCallback& callback) { |
| 105 CHECK(stream_); | |
| 106 CHECK(!request_body_stream_); | 105 CHECK(!request_body_stream_); |
| 107 CHECK(!response_info_); | 106 CHECK(!response_info_); |
| 108 CHECK(!callback.is_null()); | 107 CHECK(!callback.is_null()); |
| 109 CHECK(response); | 108 CHECK(response); |
| 110 | 109 |
| 110 if (!stream_) { |
| 111 return ERR_CONNECTION_CLOSED; |
| 112 } |
| 113 |
| 111 QuicPriority priority = ConvertRequestPriorityToQuicPriority(priority_); | 114 QuicPriority priority = ConvertRequestPriorityToQuicPriority(priority_); |
| 112 stream_->set_priority(priority); | 115 stream_->set_priority(priority); |
| 113 // Store the serialized request headers. | 116 // Store the serialized request headers. |
| 114 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, | 117 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, |
| 115 SPDY3, /*direct=*/true, &request_headers_); | 118 SPDY3, /*direct=*/true, &request_headers_); |
| 116 | 119 |
| 117 // Store the request body. | 120 // Store the request body. |
| 118 request_body_stream_ = request_info_->upload_data_stream; | 121 request_body_stream_ = request_info_->upload_data_stream; |
| 119 if (request_body_stream_) { | 122 if (request_body_stream_) { |
| 120 // TODO(rch): Can we be more precise about when to allocate | 123 // TODO(rch): Can we be more precise about when to allocate |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 348 |
| 346 bool QuicHttpStream::HasSendHeadersComplete() { | 349 bool QuicHttpStream::HasSendHeadersComplete() { |
| 347 return next_state_ > STATE_SEND_HEADERS_COMPLETE; | 350 return next_state_ > STATE_SEND_HEADERS_COMPLETE; |
| 348 } | 351 } |
| 349 | 352 |
| 350 void QuicHttpStream::OnCryptoHandshakeConfirmed() { | 353 void QuicHttpStream::OnCryptoHandshakeConfirmed() { |
| 351 was_handshake_confirmed_ = true; | 354 was_handshake_confirmed_ = true; |
| 352 } | 355 } |
| 353 | 356 |
| 354 void QuicHttpStream::OnSessionClosed(int error) { | 357 void QuicHttpStream::OnSessionClosed(int error) { |
| 358 Close(false); |
| 355 session_error_ = error; | 359 session_error_ = error; |
| 356 session_.reset(); | 360 session_.reset(); |
| 357 } | 361 } |
| 358 | 362 |
| 359 void QuicHttpStream::OnIOComplete(int rv) { | 363 void QuicHttpStream::OnIOComplete(int rv) { |
| 360 rv = DoLoop(rv); | 364 rv = DoLoop(rv); |
| 361 | 365 |
| 362 if (rv != ERR_IO_PENDING && !callback_.is_null()) { | 366 if (rv != ERR_IO_PENDING && !callback_.is_null()) { |
| 363 DoCallback(rv); | 367 DoCallback(rv); |
| 364 } | 368 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 553 |
| 550 void QuicHttpStream::BufferResponseBody(const char* data, int length) { | 554 void QuicHttpStream::BufferResponseBody(const char* data, int length) { |
| 551 if (length == 0) | 555 if (length == 0) |
| 552 return; | 556 return; |
| 553 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); | 557 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); |
| 554 memcpy(io_buffer->data(), data, length); | 558 memcpy(io_buffer->data(), data, length); |
| 555 response_body_.push_back(make_scoped_refptr(io_buffer)); | 559 response_body_.push_back(make_scoped_refptr(io_buffer)); |
| 556 } | 560 } |
| 557 | 561 |
| 558 } // namespace net | 562 } // namespace net |
| OLD | NEW |