Chromium Code Reviews| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 case STATE_SEND_HEADERS: | 745 case STATE_SEND_HEADERS: |
| 746 CHECK_EQ(result, OK); | 746 CHECK_EQ(result, OK); |
| 747 result = DoSendHeaders(); | 747 result = DoSendHeaders(); |
| 748 break; | 748 break; |
| 749 case STATE_SEND_HEADERS_COMPLETE: | 749 case STATE_SEND_HEADERS_COMPLETE: |
| 750 CHECK_EQ(result, OK); | 750 CHECK_EQ(result, OK); |
| 751 result = DoSendHeadersComplete(); | 751 result = DoSendHeadersComplete(); |
| 752 break; | 752 break; |
| 753 case STATE_SEND_BODY: | 753 case STATE_SEND_BODY: |
| 754 CHECK_EQ(result, OK); | 754 CHECK_EQ(result, OK); |
| 755 result = DoSendBody(); | 755 DoSendBody(); |
| 756 result = ERR_IO_PENDING; | |
|
Ryan Hamilton
2013/05/22 03:17:30
Yeah, this looks weird to me. I think it fits our
akalin
2013/05/22 08:40:05
Done.
| |
| 756 break; | 757 break; |
| 757 case STATE_SEND_BODY_COMPLETE: | 758 case STATE_SEND_BODY_COMPLETE: |
| 758 result = DoSendBodyComplete(result); | 759 result = DoSendBodyComplete(result); |
| 759 break; | 760 break; |
| 760 // This is an intermediary waiting state. This state is reached when all | 761 // This is an intermediary waiting state. This state is reached when all |
| 761 // data has been sent, but no data has been received. | 762 // data has been sent, but no data has been received. |
| 762 case STATE_WAITING_FOR_RESPONSE: | 763 case STATE_WAITING_FOR_RESPONSE: |
| 763 io_state_ = STATE_WAITING_FOR_RESPONSE; | 764 io_state_ = STATE_WAITING_FOR_RESPONSE; |
| 764 result = ERR_IO_PENDING; | 765 result = ERR_IO_PENDING; |
| 765 break; | 766 break; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 | 896 |
| 896 io_state_ = | 897 io_state_ = |
| 897 (delegate_->OnSendHeadersComplete() == MORE_DATA_TO_SEND) ? | 898 (delegate_->OnSendHeadersComplete() == MORE_DATA_TO_SEND) ? |
| 898 STATE_SEND_BODY : STATE_WAITING_FOR_RESPONSE; | 899 STATE_SEND_BODY : STATE_WAITING_FOR_RESPONSE; |
| 899 | 900 |
| 900 return OK; | 901 return OK; |
| 901 } | 902 } |
| 902 | 903 |
| 903 // DoSendBody is called to send the optional body for the request. This call | 904 // DoSendBody is called to send the optional body for the request. This call |
| 904 // will also be called as each write of a chunk of the body completes. | 905 // will also be called as each write of a chunk of the body completes. |
| 905 int SpdyStream::DoSendBody() { | 906 void SpdyStream::DoSendBody() { |
| 906 // If we're already in the STATE_SEND_BODY state, then we've already | 907 // If we're already in the STATE_SEND_BODY state, then we've already |
| 907 // sent a portion of the body. In that case, we need to first consume | 908 // sent a portion of the body. In that case, we need to first consume |
| 908 // the bytes written in the body stream. Note that the bytes written is | 909 // the bytes written in the body stream. Note that the bytes written is |
| 909 // the number of bytes in the frame that were written, only consume the | 910 // the number of bytes in the frame that were written, only consume the |
| 910 // data portion, of course. | 911 // data portion, of course. |
| 911 io_state_ = STATE_SEND_BODY_COMPLETE; | 912 io_state_ = STATE_SEND_BODY_COMPLETE; |
| 912 CHECK(delegate_); | 913 CHECK(delegate_); |
| 913 int status = delegate_->OnSendBody(); | 914 delegate_->OnSendBody(); |
| 914 CHECK(status == OK || status == ERR_IO_PENDING); | |
| 915 return status; | |
| 916 } | 915 } |
| 917 | 916 |
| 918 int SpdyStream::DoSendBodyComplete(int result) { | 917 int SpdyStream::DoSendBodyComplete(int result) { |
| 919 if (result != OK) | 918 if (result != OK) |
| 920 return result; | 919 return result; |
| 921 | 920 |
| 922 if (just_completed_frame_type_ != DATA) { | 921 if (just_completed_frame_type_ != DATA) { |
| 923 NOTREACHED(); | 922 NOTREACHED(); |
| 924 return ERR_UNEXPECTED; | 923 return ERR_UNEXPECTED; |
| 925 } | 924 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", | 996 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", |
| 998 recv_last_byte_time_ - recv_first_byte_time_); | 997 recv_last_byte_time_ - recv_first_byte_time_); |
| 999 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", | 998 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", |
| 1000 recv_last_byte_time_ - send_time_); | 999 recv_last_byte_time_ - send_time_); |
| 1001 | 1000 |
| 1002 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); | 1001 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); |
| 1003 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); | 1002 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); |
| 1004 } | 1003 } |
| 1005 | 1004 |
| 1006 } // namespace net | 1005 } // namespace net |
| OLD | NEW |