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

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

Issue 304353012: Introduce STATE_RESERVED_REMOTE. No behavioral changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix review remarks Created 6 years, 6 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_stream.h ('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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 SpdyStream::~SpdyStream() { 115 SpdyStream::~SpdyStream() {
116 CHECK(!write_handler_guard_); 116 CHECK(!write_handler_guard_);
117 UpdateHistograms(); 117 UpdateHistograms();
118 } 118 }
119 119
120 void SpdyStream::SetDelegate(Delegate* delegate) { 120 void SpdyStream::SetDelegate(Delegate* delegate) {
121 CHECK(!delegate_); 121 CHECK(!delegate_);
122 CHECK(delegate); 122 CHECK(delegate);
123 delegate_ = delegate; 123 delegate_ = delegate;
124 124
125 // TODO(baranovich): allow STATE_RESERVED_REMOTE when push promises will be
126 // implemented.
125 CHECK(io_state_ == STATE_IDLE || 127 CHECK(io_state_ == STATE_IDLE ||
126 io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED); 128 io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED);
127 129
128 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) { 130 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) {
129 DCHECK_EQ(type_, SPDY_PUSH_STREAM); 131 DCHECK_EQ(type_, SPDY_PUSH_STREAM);
130 base::MessageLoop::current()->PostTask( 132 base::MessageLoop::current()->PostTask(
131 FROM_HERE, 133 FROM_HERE,
132 base::Bind(&SpdyStream::PushedStreamReplay, GetWeakPtr())); 134 base::Bind(&SpdyStream::PushedStreamReplay, GetWeakPtr()));
133 } 135 }
134 } 136 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 session_->ResetStream(stream_id_, RST_STREAM_PROTOCOL_ERROR, 412 session_->ResetStream(stream_id_, RST_STREAM_PROTOCOL_ERROR,
411 "Response received before request sent"); 413 "Response received before request sent");
412 return ERR_SPDY_PROTOCOL_ERROR; 414 return ERR_SPDY_PROTOCOL_ERROR;
413 } 415 }
414 break; 416 break;
415 417
416 case SPDY_PUSH_STREAM: 418 case SPDY_PUSH_STREAM:
417 // Push streams transition to a locally half-closed state upon headers. 419 // Push streams transition to a locally half-closed state upon headers.
418 // We must continue to buffer data while waiting for a call to 420 // We must continue to buffer data while waiting for a call to
419 // SetDelegate() (which may not ever happen). 421 // SetDelegate() (which may not ever happen).
420 // TODO(jgraettinger): When PUSH_PROMISE is added, Handle RESERVED_REMOTE 422 // TODO(baranovich): For HTTP 2 push streams, delegate may be set before
421 // cases here depending on whether the delegate is already set. 423 // receiving response headers when PUSH_PROMISE will be implemented.
422 CHECK_EQ(io_state_, STATE_IDLE); 424 // TODO(baranovich): In HTTP 2 additional HEADERS frames are not allowed.
425 // Set |response_headers_status_| to RESPONSE_HEADERS_ARE_COMPLETE.
Johnny 2014/06/09 18:44:16 Current behavior is that we'll accept & merge head
426 CHECK_EQ(io_state_, STATE_RESERVED_REMOTE);
423 DCHECK(!delegate_); 427 DCHECK(!delegate_);
424 io_state_ = STATE_HALF_CLOSED_LOCAL_UNCLAIMED; 428 io_state_ = STATE_HALF_CLOSED_LOCAL_UNCLAIMED;
425 break; 429 break;
426 } 430 }
427 431
428 metrics_.StartStream(); 432 metrics_.StartStream();
429 433
430 DCHECK_NE(io_state_, STATE_IDLE); 434 DCHECK_NE(io_state_, STATE_IDLE);
431 435
432 response_time_ = response_time; 436 response_time_ = response_time;
(...skipping 11 matching lines...) Expand all
444 } else if (type_ == SPDY_PUSH_STREAM && 448 } else if (type_ == SPDY_PUSH_STREAM &&
445 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) { 449 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) {
446 session_->ResetStream( 450 session_->ResetStream(
447 stream_id_, RST_STREAM_PROTOCOL_ERROR, 451 stream_id_, RST_STREAM_PROTOCOL_ERROR,
448 "Additional headers received for push stream"); 452 "Additional headers received for push stream");
449 return ERR_SPDY_PROTOCOL_ERROR; 453 return ERR_SPDY_PROTOCOL_ERROR;
450 } 454 }
451 return MergeWithResponseHeaders(additional_response_headers); 455 return MergeWithResponseHeaders(additional_response_headers);
452 } 456 }
453 457
458 int SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) {
459 CHECK(!request_headers_.get());
460 CHECK_EQ(io_state_, STATE_IDLE);
461 CHECK_EQ(type_, SPDY_PUSH_STREAM);
462 DCHECK(!delegate_);
463
464 io_state_ = STATE_RESERVED_REMOTE;
465 request_headers_.reset(new SpdyHeaderBlock(headers));
466 return OK;
467 }
468
454 void SpdyStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { 469 void SpdyStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) {
455 DCHECK(session_->IsStreamActive(stream_id_)); 470 DCHECK(session_->IsStreamActive(stream_id_));
456 471
457 // If we're still buffering data for a push stream, we will do the 472 // If we're still buffering data for a push stream, we will do the
458 // check for data received with incomplete headers in 473 // check for data received with incomplete headers in
459 // PushedStreamReplayData(). 474 // PushedStreamReplayData().
460 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) { 475 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) {
461 DCHECK_EQ(type_, SPDY_PUSH_STREAM); 476 DCHECK_EQ(type_, SPDY_PUSH_STREAM);
462 // It should be valid for this to happen in the server push case. 477 // It should be valid for this to happen in the server push case.
463 // We'll return received data when delegate gets attached to the stream. 478 // We'll return received data when delegate gets attached to the stream.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 738 }
724 739
725 bool SpdyStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { 740 bool SpdyStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const {
726 if (stream_id_ == 0) 741 if (stream_id_ == 0)
727 return false; 742 return false;
728 743
729 return session_->GetLoadTimingInfo(stream_id_, load_timing_info); 744 return session_->GetLoadTimingInfo(stream_id_, load_timing_info);
730 } 745 }
731 746
732 GURL SpdyStream::GetUrlFromHeaders() const { 747 GURL SpdyStream::GetUrlFromHeaders() const {
733 if (type_ != SPDY_PUSH_STREAM && !request_headers_) 748 if (!request_headers_)
734 return GURL(); 749 return GURL();
735 750
736 const SpdyHeaderBlock& headers = 751 return GetUrlFromHeaderBlock(
737 (type_ == SPDY_PUSH_STREAM) ? response_headers_ : *request_headers_; 752 *request_headers_, GetProtocolVersion(), type_ == SPDY_PUSH_STREAM);
738 return GetUrlFromHeaderBlock(headers, GetProtocolVersion(),
739 type_ == SPDY_PUSH_STREAM);
740 } 753 }
741 754
742 bool SpdyStream::HasUrlFromHeaders() const { 755 bool SpdyStream::HasUrlFromHeaders() const {
743 return !GetUrlFromHeaders().is_empty(); 756 return !GetUrlFromHeaders().is_empty();
744 } 757 }
745 758
746 void SpdyStream::UpdateHistograms() { 759 void SpdyStream::UpdateHistograms() {
747 // We need at least the receive timers to be filled in, as otherwise 760 // We need at least the receive timers to be filled in, as otherwise
748 // metrics can be bogus. 761 // metrics can be bogus.
749 if (recv_first_byte_time_.is_null() || recv_last_byte_time_.is_null()) 762 if (recv_first_byte_time_.is_null() || recv_last_byte_time_.is_null())
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 902 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
890 state); 903 state);
891 break; 904 break;
892 } 905 }
893 return description; 906 return description;
894 } 907 }
895 908
896 #undef STATE_CASE 909 #undef STATE_CASE
897 910
898 } // namespace net 911 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698