| 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/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/values.h" | 18 #include "base/values.h" |
| 18 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 276 } |
| 276 | 277 |
| 277 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 278 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
| 278 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, | 279 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, |
| 279 stream_->GetProtocolVersion(), direct_, | 280 stream_->GetProtocolVersion(), direct_, |
| 280 headers.get()); | 281 headers.get()); |
| 281 stream_->net_log().AddEvent( | 282 stream_->net_log().AddEvent( |
| 282 NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS, | 283 NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS, |
| 283 base::Bind(&SpdyHeaderBlockNetLogCallback, headers.get())); | 284 base::Bind(&SpdyHeaderBlockNetLogCallback, headers.get())); |
| 284 result = stream_->SendRequestHeaders( | 285 result = stream_->SendRequestHeaders( |
| 285 headers.Pass(), | 286 std::move(headers), |
| 286 HasUploadData() ? MORE_DATA_TO_SEND : NO_MORE_DATA_TO_SEND); | 287 HasUploadData() ? MORE_DATA_TO_SEND : NO_MORE_DATA_TO_SEND); |
| 287 | 288 |
| 288 if (result == ERR_IO_PENDING) { | 289 if (result == ERR_IO_PENDING) { |
| 289 CHECK(request_callback_.is_null()); | 290 CHECK(request_callback_.is_null()); |
| 290 request_callback_ = callback; | 291 request_callback_ = callback; |
| 291 } | 292 } |
| 292 return result; | 293 return result; |
| 293 } | 294 } |
| 294 | 295 |
| 295 void SpdyHttpStream::Cancel() { | 296 void SpdyHttpStream::Cancel() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 354 |
| 354 void SpdyHttpStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { | 355 void SpdyHttpStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { |
| 355 CHECK_EQ(response_headers_status_, RESPONSE_HEADERS_ARE_COMPLETE); | 356 CHECK_EQ(response_headers_status_, RESPONSE_HEADERS_ARE_COMPLETE); |
| 356 | 357 |
| 357 // Note that data may be received for a SpdyStream prior to the user calling | 358 // Note that data may be received for a SpdyStream prior to the user calling |
| 358 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often | 359 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often |
| 359 // happen for server initiated streams. | 360 // happen for server initiated streams. |
| 360 DCHECK(stream_.get()); | 361 DCHECK(stream_.get()); |
| 361 DCHECK(!stream_->IsClosed() || stream_->type() == SPDY_PUSH_STREAM); | 362 DCHECK(!stream_->IsClosed() || stream_->type() == SPDY_PUSH_STREAM); |
| 362 if (buffer) { | 363 if (buffer) { |
| 363 response_body_queue_.Enqueue(buffer.Pass()); | 364 response_body_queue_.Enqueue(std::move(buffer)); |
| 364 | 365 |
| 365 if (user_buffer_.get()) { | 366 if (user_buffer_.get()) { |
| 366 // Handing small chunks of data to the caller creates measurable overhead. | 367 // Handing small chunks of data to the caller creates measurable overhead. |
| 367 // We buffer data in short time-spans and send a single read notification. | 368 // We buffer data in short time-spans and send a single read notification. |
| 368 ScheduleBufferedReadCallback(); | 369 ScheduleBufferedReadCallback(); |
| 369 } | 370 } |
| 370 } | 371 } |
| 371 } | 372 } |
| 372 | 373 |
| 373 void SpdyHttpStream::OnDataSent() { | 374 void SpdyHttpStream::OnDataSent() { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 void SpdyHttpStream::PopulateNetErrorDetails(NetErrorDetails* /*details*/) { | 579 void SpdyHttpStream::PopulateNetErrorDetails(NetErrorDetails* /*details*/) { |
| 579 return; | 580 return; |
| 580 } | 581 } |
| 581 | 582 |
| 582 void SpdyHttpStream::SetPriority(RequestPriority priority) { | 583 void SpdyHttpStream::SetPriority(RequestPriority priority) { |
| 583 // TODO(akalin): Plumb this through to |stream_request_| and | 584 // TODO(akalin): Plumb this through to |stream_request_| and |
| 584 // |stream_|. | 585 // |stream_|. |
| 585 } | 586 } |
| 586 | 587 |
| 587 } // namespace net | 588 } // namespace net |
| OLD | NEW |