| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "net/spdy/spdy_http_utils.h" |
| 12 #include "net/spdy/spdy_session.h" | 13 #include "net/spdy/spdy_session.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 NetLogSpdyStreamErrorParameter::NetLogSpdyStreamErrorParameter( | 17 NetLogSpdyStreamErrorParameter::NetLogSpdyStreamErrorParameter( |
| 17 SpdyStreamId stream_id, | 18 SpdyStreamId stream_id, |
| 18 int status, | 19 int status, |
| 19 const std::string& description) | 20 const std::string& description) |
| 20 : stream_id_(stream_id), | 21 : stream_id_(stream_id), |
| 21 status_(status), | 22 status_(status), |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 526 |
| 526 bool SpdyStream::HasUrl() const { | 527 bool SpdyStream::HasUrl() const { |
| 527 if (pushed_) | 528 if (pushed_) |
| 528 return response_received(); | 529 return response_received(); |
| 529 return request_.get() != NULL; | 530 return request_.get() != NULL; |
| 530 } | 531 } |
| 531 | 532 |
| 532 GURL SpdyStream::GetUrl() const { | 533 GURL SpdyStream::GetUrl() const { |
| 533 DCHECK(HasUrl()); | 534 DCHECK(HasUrl()); |
| 534 | 535 |
| 535 if (pushed_) { | 536 const SpdyHeaderBlock& headers = (pushed_) ? *response_ : *request_; |
| 536 if (GetProtocolVersion() >= 3) { | 537 return GetUrlFromHeaderBlock(headers, GetProtocolVersion(), pushed_); |
| 537 return GetUrlFromHeaderBlock(response_); | |
| 538 } else { | |
| 539 // assemble from the response | |
| 540 std::string url; | |
| 541 SpdyHeaderBlock::const_iterator it; | |
| 542 it = response_->find("url"); | |
| 543 if (it != (*response_).end()) | |
| 544 url = it->second; | |
| 545 return GURL(url); | |
| 546 } | |
| 547 } | |
| 548 | |
| 549 return GetUrlFromHeaderBlock(request_); | |
| 550 } | |
| 551 | |
| 552 GURL SpdyStream::GetUrlFromHeaderBlock( | |
| 553 const linked_ptr<SpdyHeaderBlock>& headers) const { | |
| 554 const char* scheme_header = GetProtocolVersion() >= 3 ? ":scheme" : "scheme"; | |
| 555 const char* host_header = GetProtocolVersion() >= 3 ? ":host" : "host"; | |
| 556 const char* path_header = GetProtocolVersion() >= 3 ? ":path" : "path"; | |
| 557 | |
| 558 std::string scheme; | |
| 559 std::string host_port; | |
| 560 std::string path; | |
| 561 SpdyHeaderBlock::const_iterator it; | |
| 562 it = headers->find(scheme_header); | |
| 563 if (it != (*headers).end()) | |
| 564 scheme = it->second; | |
| 565 it = headers->find(host_header); | |
| 566 if (it != (*headers).end()) | |
| 567 host_port = it->second; | |
| 568 it = headers->find(path_header); | |
| 569 if (it != (*headers).end()) | |
| 570 path = it->second; | |
| 571 std::string url = scheme + "://" + host_port + path; | |
| 572 return GURL(url); | |
| 573 } | 538 } |
| 574 | 539 |
| 575 void SpdyStream::OnGetDomainBoundCertComplete(int result) { | 540 void SpdyStream::OnGetDomainBoundCertComplete(int result) { |
| 576 DCHECK_EQ(STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, io_state_); | 541 DCHECK_EQ(STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, io_state_); |
| 577 DoLoop(result); | 542 DoLoop(result); |
| 578 } | 543 } |
| 579 | 544 |
| 580 int SpdyStream::DoLoop(int result) { | 545 int SpdyStream::DoLoop(int result) { |
| 581 do { | 546 do { |
| 582 State state = io_state_; | 547 State state = io_state_; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", | 759 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", |
| 795 recv_last_byte_time_ - recv_first_byte_time_); | 760 recv_last_byte_time_ - recv_first_byte_time_); |
| 796 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 761 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
| 797 recv_last_byte_time_ - send_time_); | 762 recv_last_byte_time_ - send_time_); |
| 798 | 763 |
| 799 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 764 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
| 800 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 765 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
| 801 } | 766 } |
| 802 | 767 |
| 803 } // namespace net | 768 } // namespace net |
| OLD | NEW |