| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // TODO(ahendrickson): This is recorded after the entire SYN_STREAM control | 333 // TODO(ahendrickson): This is recorded after the entire SYN_STREAM control |
| 334 // frame has been received and processed. Move to framer? | 334 // frame has been received and processed. Move to framer? |
| 335 response_info_->response_time = response_time; | 335 response_info_->response_time = response_time; |
| 336 | 336 |
| 337 if (user_callback_) | 337 if (user_callback_) |
| 338 DoCallback(status); | 338 DoCallback(status); |
| 339 return status; | 339 return status; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void SpdyHttpStream::OnDataReceived(const char* data, int length) { | 342 void SpdyHttpStream::OnDataReceived(const char* data, int length) { |
| 343 // JTL - delete this |
| 344 if (using_sctp()) { |
| 345 if (!using_sctp_control_stream() || stream()->syn_reply_received()) { |
| 346 printf("SpdyHttpStream::OnDataReceived: entered on stream %d " |
| 347 "(length = %d)\n", |
| 348 stream()->stream_id(), length); |
| 349 } else { |
| 350 printf("SpdyHttpStream::OnDataReceived: entered on stream %d, with " |
| 351 "syn_reply_received_ = false (length = %d)\n", |
| 352 stream()->stream_id(), length); |
| 353 } |
| 354 } |
| 343 // SpdyStream won't call us with data if the header block didn't contain a | 355 // SpdyStream won't call us with data if the header block didn't contain a |
| 344 // valid set of headers. So we don't expect to not have headers received | 356 // valid set of headers. So we don't expect to not have headers received |
| 345 // here. | 357 // here. |
| 346 DCHECK(response_headers_received_); | 358 // Exception - when using SCTP with a single dictionary, all SPDY CONTROL |
| 359 // frames are sent on SCTP stream 0, while all SPDY DATA frames are sent on |
| 360 // SCTP stream n > 0. This means that data can arrive before a SYN_REPLY, |
| 361 // due to reordering or loss. In this case we can't require |
| 362 // response_headers_received to be true. |
| 363 if ( !(using_sctp() && using_sctp_control_stream())) |
| 364 DCHECK(response_headers_received_); |
| 347 | 365 |
| 348 // Note that data may be received for a SpdyStream prior to the user calling | 366 // Note that data may be received for a SpdyStream prior to the user calling |
| 349 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often | 367 // ReadResponseBody(), therefore user_buffer_ may be NULL. This may often |
| 350 // happen for server initiated streams. | 368 // happen for server initiated streams. |
| 351 DCHECK(!stream_->closed() || stream_->pushed()); | 369 DCHECK(!stream_->closed() || stream_->pushed()); |
| 352 if (length > 0) { | 370 if (length > 0) { |
| 353 // Save the received data. | 371 // Save the received data. |
| 354 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); | 372 IOBufferWithSize* io_buffer = new IOBufferWithSize(length); |
| 355 memcpy(io_buffer->data(), data, length); | 373 memcpy(io_buffer->data(), data, length); |
| 356 response_body_.push_back(make_scoped_refptr(io_buffer)); | 374 response_body_.push_back(make_scoped_refptr(io_buffer)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 375 // We need to complete any pending buffered read now. | 393 // We need to complete any pending buffered read now. |
| 376 invoked_callback = DoBufferedReadCallback(); | 394 invoked_callback = DoBufferedReadCallback(); |
| 377 } | 395 } |
| 378 if (!invoked_callback && user_callback_) | 396 if (!invoked_callback && user_callback_) |
| 379 DoCallback(status); | 397 DoCallback(status); |
| 380 } | 398 } |
| 381 | 399 |
| 382 void SpdyHttpStream::ScheduleBufferedReadCallback() { | 400 void SpdyHttpStream::ScheduleBufferedReadCallback() { |
| 383 // If there is already a scheduled DoBufferedReadCallback, don't issue | 401 // If there is already a scheduled DoBufferedReadCallback, don't issue |
| 384 // another one. Mark that we have received more data and return. | 402 // another one. Mark that we have received more data and return. |
| 403 if (using_sctp() && using_sctp_control_stream() && |
| 404 !stream()->syn_reply_received()) { |
| 405 printf("SpdyHttpStream::ScheduleBufferedReadCallback: SYN_REPLY is " |
| 406 "*** pending *** on stream %d\n", stream()->stream_id()); // JTL |
| 407 } |
| 385 if (buffered_read_callback_pending_) { | 408 if (buffered_read_callback_pending_) { |
| 386 more_read_data_pending_ = true; | 409 more_read_data_pending_ = true; |
| 387 return; | 410 return; |
| 388 } | 411 } |
| 389 | 412 |
| 390 more_read_data_pending_ = false; | 413 more_read_data_pending_ = false; |
| 391 buffered_read_callback_pending_ = true; | 414 buffered_read_callback_pending_ = true; |
| 392 const int kBufferTimeMs = 1; | 415 const int kBufferTimeMs = 1; |
| 393 MessageLoop::current()->PostDelayedTask(FROM_HERE, read_callback_factory_. | 416 MessageLoop::current()->PostDelayedTask(FROM_HERE, read_callback_factory_. |
| 394 NewRunnableMethod(&SpdyHttpStream::DoBufferedReadCallback), | 417 NewRunnableMethod(&SpdyHttpStream::DoBufferedReadCallback), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 SSLCertRequestInfo* cert_request_info) { | 484 SSLCertRequestInfo* cert_request_info) { |
| 462 DCHECK(stream_); | 485 DCHECK(stream_); |
| 463 stream_->GetSSLCertRequestInfo(cert_request_info); | 486 stream_->GetSSLCertRequestInfo(cert_request_info); |
| 464 } | 487 } |
| 465 | 488 |
| 466 bool SpdyHttpStream::IsSpdyHttpStream() const { | 489 bool SpdyHttpStream::IsSpdyHttpStream() const { |
| 467 return true; | 490 return true; |
| 468 } | 491 } |
| 469 | 492 |
| 470 } // namespace net | 493 } // namespace net |
| OLD | NEW |