Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: net/spdy/spdy_stream.cc

Issue 1828203005: Expose SPDY pushes in DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed tests Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 CHECK_EQ(type_, SPDY_PUSH_STREAM); 469 CHECK_EQ(type_, SPDY_PUSH_STREAM);
470 DCHECK(!delegate_); 470 DCHECK(!delegate_);
471 471
472 io_state_ = STATE_RESERVED_REMOTE; 472 io_state_ = STATE_RESERVED_REMOTE;
473 request_headers_.reset(new SpdyHeaderBlock(headers)); 473 request_headers_.reset(new SpdyHeaderBlock(headers));
474 } 474 }
475 475
476 void SpdyStream::OnDataReceived(std::unique_ptr<SpdyBuffer> buffer) { 476 void SpdyStream::OnDataReceived(std::unique_ptr<SpdyBuffer> buffer) {
477 DCHECK(session_->IsStreamActive(stream_id_)); 477 DCHECK(session_->IsStreamActive(stream_id_));
478 478
479 // Track our bandwidth.
480 recv_bytes_ += buffer ? buffer->GetRemainingSize() : 0;
481 recv_last_byte_time_ = base::TimeTicks::Now();
482
479 // If we're still buffering data for a push stream, we will do the 483 // If we're still buffering data for a push stream, we will do the
480 // check for data received with incomplete headers in 484 // check for data received with incomplete headers in
481 // PushedStreamReplayData(). 485 // PushedStreamReplayData().
482 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) { 486 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) {
483 DCHECK_EQ(type_, SPDY_PUSH_STREAM); 487 DCHECK_EQ(type_, SPDY_PUSH_STREAM);
484 // It should be valid for this to happen in the server push case. 488 // It should be valid for this to happen in the server push case.
485 // We'll return received data when delegate gets attached to the stream. 489 // We'll return received data when delegate gets attached to the stream.
486 if (buffer) { 490 if (buffer) {
487 pending_recv_data_.push_back(std::move(buffer)); 491 pending_recv_data_.push_back(std::move(buffer));
488 } else { 492 } else {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 size_t length = buffer->GetRemainingSize(); 534 size_t length = buffer->GetRemainingSize();
531 DCHECK_LE(length, session_->GetDataFrameMaximumPayload()); 535 DCHECK_LE(length, session_->GetDataFrameMaximumPayload());
532 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); 536 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr();
533 // May close the stream. 537 // May close the stream.
534 DecreaseRecvWindowSize(static_cast<int32_t>(length)); 538 DecreaseRecvWindowSize(static_cast<int32_t>(length));
535 if (!weak_this) 539 if (!weak_this)
536 return; 540 return;
537 buffer->AddConsumeCallback( 541 buffer->AddConsumeCallback(
538 base::Bind(&SpdyStream::OnReadBufferConsumed, GetWeakPtr())); 542 base::Bind(&SpdyStream::OnReadBufferConsumed, GetWeakPtr()));
539 543
540 // Track our bandwidth.
541 recv_bytes_ += length;
542 recv_last_byte_time_ = base::TimeTicks::Now();
543
544 // May close |this|. 544 // May close |this|.
545 delegate_->OnDataReceived(std::move(buffer)); 545 delegate_->OnDataReceived(std::move(buffer));
546 } 546 }
547 547
548 void SpdyStream::OnPaddingConsumed(size_t len) { 548 void SpdyStream::OnPaddingConsumed(size_t len) {
549 // Decrease window size because padding bytes are received. 549 // Decrease window size because padding bytes are received.
550 // Increase window size because padding bytes are consumed (by discarding). 550 // Increase window size because padding bytes are consumed (by discarding).
551 // Net result: |unacked_recv_window_bytes_| increases by |len|, 551 // Net result: |unacked_recv_window_bytes_| increases by |len|,
552 // |recv_window_size_| does not change. 552 // |recv_window_size_| does not change.
553 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); 553 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr();
(...skipping 11 matching lines...) Expand all
565 frame_type == DATA) << frame_type; 565 frame_type == DATA) << frame_type;
566 566
567 int result = (frame_type == SYN_STREAM) ? 567 int result = (frame_type == SYN_STREAM) ?
568 OnRequestHeadersSent() : OnDataSent(frame_size); 568 OnRequestHeadersSent() : OnDataSent(frame_size);
569 if (result == ERR_IO_PENDING) { 569 if (result == ERR_IO_PENDING) {
570 // The write operation hasn't completed yet. 570 // The write operation hasn't completed yet.
571 return; 571 return;
572 } 572 }
573 573
574 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) { 574 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) {
575 if(io_state_ == STATE_OPEN) { 575 if (io_state_ == STATE_OPEN) {
576 io_state_ = STATE_HALF_CLOSED_LOCAL; 576 io_state_ = STATE_HALF_CLOSED_LOCAL;
577 } else if(io_state_ == STATE_HALF_CLOSED_REMOTE) { 577 } else if (io_state_ == STATE_HALF_CLOSED_REMOTE) {
578 io_state_ = STATE_CLOSED; 578 io_state_ = STATE_CLOSED;
579 } else { 579 } else {
580 NOTREACHED() << io_state_; 580 NOTREACHED() << io_state_;
581 } 581 }
582 } 582 }
583 // Notify delegate of write completion. Must not destroy |this|. 583 // Notify delegate of write completion. Must not destroy |this|.
584 CHECK(delegate_); 584 CHECK(delegate_);
585 { 585 {
586 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); 586 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr();
587 write_handler_guard_ = true; 587 write_handler_guard_ = true;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 raw_received_bytes_ += received_bytes; 763 raw_received_bytes_ += received_bytes;
764 } 764 }
765 765
766 void SpdyStream::AddRawSentBytes(size_t sent_bytes) { 766 void SpdyStream::AddRawSentBytes(size_t sent_bytes) {
767 raw_sent_bytes_ += sent_bytes; 767 raw_sent_bytes_ += sent_bytes;
768 } 768 }
769 769
770 bool SpdyStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { 770 bool SpdyStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const {
771 if (stream_id_ == 0) 771 if (stream_id_ == 0)
772 return false; 772 return false;
773 773 bool result = session_->GetLoadTimingInfo(stream_id_, load_timing_info);
774 return session_->GetLoadTimingInfo(stream_id_, load_timing_info); 774 if (type_ == SPDY_PUSH_STREAM) {
775 load_timing_info->push_start = recv_first_byte_time_;
776 bool done_receiving = IsClosed() || (!pending_recv_data_.empty() &&
777 !pending_recv_data_.back());
778 if (done_receiving)
779 load_timing_info->push_end = recv_last_byte_time_;
780 }
781 return result;
775 } 782 }
776 783
777 GURL SpdyStream::GetUrlFromHeaders() const { 784 GURL SpdyStream::GetUrlFromHeaders() const {
778 if (!request_headers_) 785 if (!request_headers_)
779 return GURL(); 786 return GURL();
780 787
781 return GetUrlFromHeaderBlock(*request_headers_, GetProtocolVersion()); 788 return GetUrlFromHeaderBlock(*request_headers_, GetProtocolVersion());
782 } 789 }
783 790
784 bool SpdyStream::HasUrlFromHeaders() const { 791 bool SpdyStream::HasUrlFromHeaders() const {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 945 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
939 state); 946 state);
940 break; 947 break;
941 } 948 }
942 return description; 949 return description;
943 } 950 }
944 951
945 #undef STATE_CASE 952 #undef STATE_CASE
946 953
947 } // namespace net 954 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698