| 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_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 sent_settings_(false), | 648 sent_settings_(false), |
| 649 received_settings_(false), | 649 received_settings_(false), |
| 650 stalled_streams_(0), | 650 stalled_streams_(0), |
| 651 pings_in_flight_(0), | 651 pings_in_flight_(0), |
| 652 next_ping_id_(1), | 652 next_ping_id_(1), |
| 653 last_activity_time_(time_func()), | 653 last_activity_time_(time_func()), |
| 654 last_compressed_frame_len_(0), | 654 last_compressed_frame_len_(0), |
| 655 check_ping_status_pending_(false), | 655 check_ping_status_pending_(false), |
| 656 send_connection_header_prefix_(false), | 656 send_connection_header_prefix_(false), |
| 657 flow_control_state_(FLOW_CONTROL_NONE), | 657 flow_control_state_(FLOW_CONTROL_NONE), |
| 658 stream_initial_send_window_size_(kSpdyStreamInitialWindowSize), | 658 stream_initial_send_window_size_(GetInitialWindowSize(default_protocol)), |
| 659 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 | 659 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 |
| 660 ? kDefaultInitialRecvWindowSize | 660 ? kDefaultInitialRecvWindowSize |
| 661 : stream_initial_recv_window_size), | 661 : stream_initial_recv_window_size), |
| 662 session_send_window_size_(0), | 662 session_send_window_size_(0), |
| 663 session_recv_window_size_(0), | 663 session_recv_window_size_(0), |
| 664 session_unacked_recv_window_bytes_(0), | 664 session_unacked_recv_window_bytes_(0), |
| 665 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), | 665 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)), |
| 666 verify_domain_authentication_(verify_domain_authentication), | 666 verify_domain_authentication_(verify_domain_authentication), |
| 667 enable_sending_initial_data_(enable_sending_initial_data), | 667 enable_sending_initial_data_(enable_sending_initial_data), |
| 668 enable_compression_(enable_compression), | 668 enable_compression_(enable_compression), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 spdy_sessions.Increment(); | 722 spdy_sessions.Increment(); |
| 723 | 723 |
| 724 connection_ = connection.Pass(); | 724 connection_ = connection.Pass(); |
| 725 is_secure_ = is_secure; | 725 is_secure_ = is_secure; |
| 726 certificate_error_code_ = certificate_error_code; | 726 certificate_error_code_ = certificate_error_code; |
| 727 | 727 |
| 728 NextProto protocol_negotiated = | 728 NextProto protocol_negotiated = |
| 729 connection_->socket()->GetNegotiatedProtocol(); | 729 connection_->socket()->GetNegotiatedProtocol(); |
| 730 if (protocol_negotiated != kProtoUnknown) { | 730 if (protocol_negotiated != kProtoUnknown) { |
| 731 protocol_ = protocol_negotiated; | 731 protocol_ = protocol_negotiated; |
| 732 stream_initial_send_window_size_ = GetInitialWindowSize(protocol_); |
| 732 } | 733 } |
| 733 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); | 734 DCHECK_GE(protocol_, kProtoSPDYMinimumVersion); |
| 734 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); | 735 DCHECK_LE(protocol_, kProtoSPDYMaximumVersion); |
| 735 | 736 |
| 736 if ((protocol_ >= kProtoSPDY4MinimumVersion) && | 737 if ((protocol_ >= kProtoSPDY4MinimumVersion) && |
| 737 (protocol_ <= kProtoSPDY4MaximumVersion)) | 738 (protocol_ <= kProtoSPDY4MaximumVersion)) |
| 738 send_connection_header_prefix_ = true; | 739 send_connection_header_prefix_ = true; |
| 739 | 740 |
| 740 if (protocol_ >= kProtoSPDY31) { | 741 if (protocol_ >= kProtoSPDY31) { |
| 741 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; | 742 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; |
| 742 session_send_window_size_ = kSpdySessionInitialWindowSize; | 743 session_send_window_size_ = GetInitialWindowSize(protocol_); |
| 743 session_recv_window_size_ = kSpdySessionInitialWindowSize; | 744 session_recv_window_size_ = GetInitialWindowSize(protocol_); |
| 744 } else if (protocol_ >= kProtoSPDY3) { | 745 } else if (protocol_ >= kProtoSPDY3) { |
| 745 flow_control_state_ = FLOW_CONTROL_STREAM; | 746 flow_control_state_ = FLOW_CONTROL_STREAM; |
| 746 } else { | 747 } else { |
| 747 flow_control_state_ = FLOW_CONTROL_NONE; | 748 flow_control_state_ = FLOW_CONTROL_NONE; |
| 748 } | 749 } |
| 749 | 750 |
| 750 buffered_spdy_framer_.reset( | 751 buffered_spdy_framer_.reset( |
| 751 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), | 752 new BufferedSpdyFramer(NextProtoToSpdyMajorVersion(protocol_), |
| 752 enable_compression_)); | 753 enable_compression_)); |
| 753 buffered_spdy_framer_->set_visitor(this); | 754 buffered_spdy_framer_->set_visitor(this); |
| (...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 } | 2772 } |
| 2772 | 2773 |
| 2773 // First, notify the server about the settings they should use when | 2774 // First, notify the server about the settings they should use when |
| 2774 // communicating with us. | 2775 // communicating with us. |
| 2775 SettingsMap settings_map; | 2776 SettingsMap settings_map; |
| 2776 // Create a new settings frame notifying the server of our | 2777 // Create a new settings frame notifying the server of our |
| 2777 // max concurrent streams and initial window size. | 2778 // max concurrent streams and initial window size. |
| 2778 settings_map[SETTINGS_MAX_CONCURRENT_STREAMS] = | 2779 settings_map[SETTINGS_MAX_CONCURRENT_STREAMS] = |
| 2779 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); | 2780 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); |
| 2780 if (flow_control_state_ >= FLOW_CONTROL_STREAM && | 2781 if (flow_control_state_ >= FLOW_CONTROL_STREAM && |
| 2781 stream_initial_recv_window_size_ != kSpdyStreamInitialWindowSize) { | 2782 stream_initial_recv_window_size_ != GetInitialWindowSize(protocol_)) { |
| 2782 settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = | 2783 settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = |
| 2783 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, | 2784 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, |
| 2784 stream_initial_recv_window_size_); | 2785 stream_initial_recv_window_size_); |
| 2785 } | 2786 } |
| 2786 SendSettings(settings_map); | 2787 SendSettings(settings_map); |
| 2787 | 2788 |
| 2788 // Next, notify the server about our initial recv window size. | 2789 // Next, notify the server about our initial recv window size. |
| 2789 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { | 2790 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { |
| 2790 // Bump up the receive window size to the real initial value. This | 2791 // Bump up the receive window size to the real initial value. This |
| 2791 // has to go here since the WINDOW_UPDATE frame sent by | 2792 // has to go here since the WINDOW_UPDATE frame sent by |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3188 // Check for overflow. | 3189 // Check for overflow. |
| 3189 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); | 3190 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); |
| 3190 | 3191 |
| 3191 session_recv_window_size_ += delta_window_size; | 3192 session_recv_window_size_ += delta_window_size; |
| 3192 net_log_.AddEvent( | 3193 net_log_.AddEvent( |
| 3193 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, | 3194 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, |
| 3194 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3195 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
| 3195 delta_window_size, session_recv_window_size_)); | 3196 delta_window_size, session_recv_window_size_)); |
| 3196 | 3197 |
| 3197 session_unacked_recv_window_bytes_ += delta_window_size; | 3198 session_unacked_recv_window_bytes_ += delta_window_size; |
| 3198 if (session_unacked_recv_window_bytes_ > kSpdySessionInitialWindowSize / 2) { | 3199 if (session_unacked_recv_window_bytes_ > |
| 3200 GetInitialWindowSize(protocol_) / 2) { |
| 3199 SendWindowUpdateFrame(kSessionFlowControlStreamId, | 3201 SendWindowUpdateFrame(kSessionFlowControlStreamId, |
| 3200 session_unacked_recv_window_bytes_, | 3202 session_unacked_recv_window_bytes_, |
| 3201 HIGHEST); | 3203 HIGHEST); |
| 3202 session_unacked_recv_window_bytes_ = 0; | 3204 session_unacked_recv_window_bytes_ = 0; |
| 3203 } | 3205 } |
| 3204 } | 3206 } |
| 3205 | 3207 |
| 3206 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { | 3208 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { |
| 3207 CHECK(in_io_loop_); | 3209 CHECK(in_io_loop_); |
| 3208 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3210 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3272 if (!queue->empty()) { | 3274 if (!queue->empty()) { |
| 3273 SpdyStreamId stream_id = queue->front(); | 3275 SpdyStreamId stream_id = queue->front(); |
| 3274 queue->pop_front(); | 3276 queue->pop_front(); |
| 3275 return stream_id; | 3277 return stream_id; |
| 3276 } | 3278 } |
| 3277 } | 3279 } |
| 3278 return 0; | 3280 return 0; |
| 3279 } | 3281 } |
| 3280 | 3282 |
| 3281 } // namespace net | 3283 } // namespace net |
| OLD | NEW |