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/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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 125 // TODO(baranovich): allow STATE_RESERVED_REMOTE when push promises will be |
126 // implemented. | 126 // implemented. |
Johnny
2014/06/17 04:01:33
Remove TODO
baranovich
2014/06/17 21:33:43
Done.
| |
127 CHECK(io_state_ == STATE_IDLE || | 127 CHECK(io_state_ == STATE_IDLE || |
128 io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED); | 128 io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED || |
129 io_state_ == STATE_RESERVED_REMOTE); | |
129 | 130 |
130 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) { | 131 if (io_state_ == STATE_HALF_CLOSED_LOCAL_UNCLAIMED) { |
131 DCHECK_EQ(type_, SPDY_PUSH_STREAM); | 132 DCHECK_EQ(type_, SPDY_PUSH_STREAM); |
132 base::MessageLoop::current()->PostTask( | 133 base::MessageLoop::current()->PostTask( |
133 FROM_HERE, | 134 FROM_HERE, |
134 base::Bind(&SpdyStream::PushedStreamReplay, GetWeakPtr())); | 135 base::Bind(&SpdyStream::PushedStreamReplay, GetWeakPtr())); |
135 } | 136 } |
136 } | 137 } |
137 | 138 |
138 void SpdyStream::PushedStreamReplay() { | 139 void SpdyStream::PushedStreamReplay() { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 session_->ResetStream(stream_id_, RST_STREAM_PROTOCOL_ERROR, | 413 session_->ResetStream(stream_id_, RST_STREAM_PROTOCOL_ERROR, |
413 "Response received before request sent"); | 414 "Response received before request sent"); |
414 return ERR_SPDY_PROTOCOL_ERROR; | 415 return ERR_SPDY_PROTOCOL_ERROR; |
415 } | 416 } |
416 break; | 417 break; |
417 | 418 |
418 case SPDY_PUSH_STREAM: | 419 case SPDY_PUSH_STREAM: |
419 // Push streams transition to a locally half-closed state upon headers. | 420 // Push streams transition to a locally half-closed state upon headers. |
420 // We must continue to buffer data while waiting for a call to | 421 // We must continue to buffer data while waiting for a call to |
421 // SetDelegate() (which may not ever happen). | 422 // SetDelegate() (which may not ever happen). |
422 // TODO(baranovich): For HTTP 2 push streams, delegate may be set before | |
423 // receiving response headers when PUSH_PROMISE will be implemented. | |
424 // TODO(baranovich): In HTTP 2 additional HEADERS frames are not allowed. | |
425 // Set |response_headers_status_| to RESPONSE_HEADERS_ARE_COMPLETE. | |
426 CHECK_EQ(io_state_, STATE_RESERVED_REMOTE); | 423 CHECK_EQ(io_state_, STATE_RESERVED_REMOTE); |
427 DCHECK(!delegate_); | 424 if (!delegate_) { |
428 io_state_ = STATE_HALF_CLOSED_LOCAL_UNCLAIMED; | 425 io_state_ = STATE_HALF_CLOSED_LOCAL_UNCLAIMED; |
426 } else { | |
427 io_state_ = STATE_HALF_CLOSED_LOCAL; | |
428 } | |
429 break; | 429 break; |
430 } | 430 } |
431 | 431 |
432 metrics_.StartStream(); | 432 metrics_.StartStream(); |
433 | 433 |
434 DCHECK_NE(io_state_, STATE_IDLE); | 434 DCHECK_NE(io_state_, STATE_IDLE); |
435 | 435 |
436 response_time_ = response_time; | 436 response_time_ = response_time; |
437 recv_first_byte_time_ = recv_first_byte_time; | 437 recv_first_byte_time_ = recv_first_byte_time; |
438 return MergeWithResponseHeaders(initial_response_headers); | 438 return MergeWithResponseHeaders(initial_response_headers); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 902 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
903 state); | 903 state); |
904 break; | 904 break; |
905 } | 905 } |
906 return description; | 906 return description; |
907 } | 907 } |
908 | 908 |
909 #undef STATE_CASE | 909 #undef STATE_CASE |
910 | 910 |
911 } // namespace net | 911 } // namespace net |
OLD | NEW |