| 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_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 DoLoop(bytes); | 433 DoLoop(bytes); |
| 434 } | 434 } |
| 435 | 435 |
| 436 void SpdyStream::OnChunkAvailable() { | 436 void SpdyStream::OnChunkAvailable() { |
| 437 DCHECK(io_state_ == STATE_SEND_HEADERS || io_state_ == STATE_SEND_BODY || | 437 DCHECK(io_state_ == STATE_SEND_HEADERS || io_state_ == STATE_SEND_BODY || |
| 438 io_state_ == STATE_SEND_BODY_COMPLETE); | 438 io_state_ == STATE_SEND_BODY_COMPLETE); |
| 439 if (io_state_ == STATE_SEND_BODY) | 439 if (io_state_ == STATE_SEND_BODY) |
| 440 OnWriteComplete(0); | 440 OnWriteComplete(0); |
| 441 } | 441 } |
| 442 | 442 |
| 443 int SpdyStream::GetProtocolVersion() const { |
| 444 return session_->GetProtocolVersion(); |
| 445 } |
| 446 |
| 443 void SpdyStream::LogStreamError(int status, const std::string& description) { | 447 void SpdyStream::LogStreamError(int status, const std::string& description) { |
| 444 net_log_.AddEvent( | 448 net_log_.AddEvent( |
| 445 NetLog::TYPE_SPDY_STREAM_ERROR, | 449 NetLog::TYPE_SPDY_STREAM_ERROR, |
| 446 make_scoped_refptr( | 450 make_scoped_refptr( |
| 447 new NetLogSpdyStreamErrorParameter(stream_id_, status, description))); | 451 new NetLogSpdyStreamErrorParameter(stream_id_, status, description))); |
| 448 } | 452 } |
| 449 | 453 |
| 450 void SpdyStream::OnClose(int status) { | 454 void SpdyStream::OnClose(int status) { |
| 451 io_state_ = STATE_DONE; | 455 io_state_ = STATE_DONE; |
| 452 response_status_ = status; | 456 response_status_ = status; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 bool SpdyStream::HasUrl() const { | 513 bool SpdyStream::HasUrl() const { |
| 510 if (pushed_) | 514 if (pushed_) |
| 511 return response_received(); | 515 return response_received(); |
| 512 return request_.get() != NULL; | 516 return request_.get() != NULL; |
| 513 } | 517 } |
| 514 | 518 |
| 515 GURL SpdyStream::GetUrl() const { | 519 GURL SpdyStream::GetUrl() const { |
| 516 DCHECK(HasUrl()); | 520 DCHECK(HasUrl()); |
| 517 | 521 |
| 518 if (pushed_) { | 522 if (pushed_) { |
| 519 // assemble from the response | 523 if (GetProtocolVersion() >= 3) { |
| 520 std::string url; | 524 return GetUrlFromHeaderBlock(response_); |
| 521 spdy::SpdyHeaderBlock::const_iterator it; | 525 } else { |
| 522 it = response_->find("url"); | 526 // assemble from the response |
| 523 if (it != (*response_).end()) | 527 std::string url; |
| 524 url = it->second; | 528 spdy::SpdyHeaderBlock::const_iterator it; |
| 525 return GURL(url); | 529 it = response_->find("url"); |
| 530 if (it != (*response_).end()) |
| 531 url = it->second; |
| 532 return GURL(url); |
| 533 } |
| 526 } | 534 } |
| 527 | 535 |
| 528 // assemble from the request | 536 return GetUrlFromHeaderBlock(request_); |
| 537 } |
| 538 |
| 539 GURL SpdyStream::GetUrlFromHeaderBlock( |
| 540 const linked_ptr<spdy::SpdyHeaderBlock>& headers) const { |
| 541 const char* scheme_header = GetProtocolVersion() >= 3 ? ":scheme" : "scheme"; |
| 542 const char* host_header = GetProtocolVersion() >= 3 ? ":host" : "host"; |
| 543 const char* path_header = GetProtocolVersion() >= 3 ? ":path" : "path"; |
| 544 |
| 529 std::string scheme; | 545 std::string scheme; |
| 530 std::string host_port; | 546 std::string host_port; |
| 531 std::string path; | 547 std::string path; |
| 532 spdy::SpdyHeaderBlock::const_iterator it; | 548 spdy::SpdyHeaderBlock::const_iterator it; |
| 533 it = request_->find("scheme"); | 549 it = headers->find(scheme_header); |
| 534 if (it != (*request_).end()) | 550 if (it != (*headers).end()) |
| 535 scheme = it->second; | 551 scheme = it->second; |
| 536 it = request_->find("host"); | 552 it = headers->find(host_header); |
| 537 if (it != (*request_).end()) | 553 if (it != (*headers).end()) |
| 538 host_port = it->second; | 554 host_port = it->second; |
| 539 it = request_->find("path"); | 555 it = headers->find(path_header); |
| 540 if (it != (*request_).end()) | 556 if (it != (*headers).end()) |
| 541 path = it->second; | 557 path = it->second; |
| 542 std::string url = scheme + "://" + host_port + path; | 558 std::string url = scheme + "://" + host_port + path; |
| 543 return GURL(url); | 559 return GURL(url); |
| 544 } | 560 } |
| 545 | 561 |
| 546 void SpdyStream::OnGetOriginBoundCertComplete(int result) { | 562 void SpdyStream::OnGetOriginBoundCertComplete(int result) { |
| 547 DCHECK_EQ(STATE_GET_ORIGIN_BOUND_CERT_COMPLETE, io_state_); | 563 DCHECK_EQ(STATE_GET_ORIGIN_BOUND_CERT_COMPLETE, io_state_); |
| 548 DoLoop(result); | 564 DoLoop(result); |
| 549 } | 565 } |
| 550 | 566 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", | 774 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", |
| 759 recv_last_byte_time_ - recv_first_byte_time_); | 775 recv_last_byte_time_ - recv_first_byte_time_); |
| 760 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 776 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
| 761 recv_last_byte_time_ - send_time_); | 777 recv_last_byte_time_ - send_time_); |
| 762 | 778 |
| 763 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 779 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
| 764 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 780 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
| 765 } | 781 } |
| 766 | 782 |
| 767 } // namespace net | 783 } // namespace net |
| OLD | NEW |