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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 601 |
602 SpdySession::SpdySession( | 602 SpdySession::SpdySession( |
603 const SpdySessionKey& spdy_session_key, | 603 const SpdySessionKey& spdy_session_key, |
604 const base::WeakPtr<HttpServerProperties>& http_server_properties, | 604 const base::WeakPtr<HttpServerProperties>& http_server_properties, |
605 TransportSecurityState* transport_security_state, | 605 TransportSecurityState* transport_security_state, |
606 bool verify_domain_authentication, | 606 bool verify_domain_authentication, |
607 bool enable_sending_initial_data, | 607 bool enable_sending_initial_data, |
608 bool enable_compression, | 608 bool enable_compression, |
609 bool enable_ping_based_connection_checking, | 609 bool enable_ping_based_connection_checking, |
610 NextProto default_protocol, | 610 NextProto default_protocol, |
| 611 size_t session_max_recv_window_size, |
611 size_t stream_initial_recv_window_size, | 612 size_t stream_initial_recv_window_size, |
612 size_t initial_max_concurrent_streams, | 613 size_t initial_max_concurrent_streams, |
613 size_t max_concurrent_streams_limit, | 614 size_t max_concurrent_streams_limit, |
614 TimeFunc time_func, | 615 TimeFunc time_func, |
615 const HostPortPair& trusted_spdy_proxy, | 616 const HostPortPair& trusted_spdy_proxy, |
616 NetLog* net_log) | 617 NetLog* net_log) |
617 : in_io_loop_(false), | 618 : in_io_loop_(false), |
618 spdy_session_key_(spdy_session_key), | 619 spdy_session_key_(spdy_session_key), |
619 pool_(NULL), | 620 pool_(NULL), |
620 http_server_properties_(http_server_properties), | 621 http_server_properties_(http_server_properties), |
(...skipping 26 matching lines...) Expand all Loading... |
647 sent_settings_(false), | 648 sent_settings_(false), |
648 received_settings_(false), | 649 received_settings_(false), |
649 stalled_streams_(0), | 650 stalled_streams_(0), |
650 pings_in_flight_(0), | 651 pings_in_flight_(0), |
651 next_ping_id_(1), | 652 next_ping_id_(1), |
652 last_activity_time_(time_func()), | 653 last_activity_time_(time_func()), |
653 last_compressed_frame_len_(0), | 654 last_compressed_frame_len_(0), |
654 check_ping_status_pending_(false), | 655 check_ping_status_pending_(false), |
655 send_connection_header_prefix_(false), | 656 send_connection_header_prefix_(false), |
656 flow_control_state_(FLOW_CONTROL_NONE), | 657 flow_control_state_(FLOW_CONTROL_NONE), |
| 658 session_send_window_size_(0), |
| 659 session_max_recv_window_size_(session_max_recv_window_size == 0 |
| 660 ? kDefaultInitialRecvWindowSize |
| 661 : session_max_recv_window_size), |
| 662 session_recv_window_size_(0), |
| 663 session_unacked_recv_window_bytes_(0), |
657 stream_initial_send_window_size_(GetInitialWindowSize(default_protocol)), | 664 stream_initial_send_window_size_(GetInitialWindowSize(default_protocol)), |
658 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 | 665 stream_initial_recv_window_size_(stream_initial_recv_window_size == 0 |
659 ? kDefaultInitialRecvWindowSize | 666 ? kDefaultInitialRecvWindowSize |
660 : stream_initial_recv_window_size), | 667 : stream_initial_recv_window_size), |
661 session_send_window_size_(0), | |
662 session_recv_window_size_(0), | |
663 session_unacked_recv_window_bytes_(0), | |
664 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP2_SESSION)), | 668 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP2_SESSION)), |
665 verify_domain_authentication_(verify_domain_authentication), | 669 verify_domain_authentication_(verify_domain_authentication), |
666 enable_sending_initial_data_(enable_sending_initial_data), | 670 enable_sending_initial_data_(enable_sending_initial_data), |
667 enable_compression_(enable_compression), | 671 enable_compression_(enable_compression), |
668 enable_ping_based_connection_checking_( | 672 enable_ping_based_connection_checking_( |
669 enable_ping_based_connection_checking), | 673 enable_ping_based_connection_checking), |
670 protocol_(default_protocol), | 674 protocol_(default_protocol), |
671 connection_at_risk_of_loss_time_( | 675 connection_at_risk_of_loss_time_( |
672 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), | 676 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), |
673 hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), | 677 hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), |
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2779 if (flow_control_state_ >= FLOW_CONTROL_STREAM && | 2783 if (flow_control_state_ >= FLOW_CONTROL_STREAM && |
2780 stream_initial_recv_window_size_ != GetInitialWindowSize(protocol_)) { | 2784 stream_initial_recv_window_size_ != GetInitialWindowSize(protocol_)) { |
2781 settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = | 2785 settings_map[SETTINGS_INITIAL_WINDOW_SIZE] = |
2782 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, | 2786 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, |
2783 stream_initial_recv_window_size_); | 2787 stream_initial_recv_window_size_); |
2784 } | 2788 } |
2785 SendSettings(settings_map); | 2789 SendSettings(settings_map); |
2786 | 2790 |
2787 // Next, notify the server about our initial recv window size. | 2791 // Next, notify the server about our initial recv window size. |
2788 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { | 2792 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { |
| 2793 if (session_max_recv_window_size_ == 0) { |
| 2794 session_max_recv_window_size_ = kDefaultInitialRecvWindowSize; |
| 2795 } |
2789 // Bump up the receive window size to the real initial value. This | 2796 // Bump up the receive window size to the real initial value. This |
2790 // has to go here since the WINDOW_UPDATE frame sent by | 2797 // has to go here since the WINDOW_UPDATE frame sent by |
2791 // IncreaseRecvWindowSize() call uses |buffered_spdy_framer_|. | 2798 // IncreaseRecvWindowSize() call uses |buffered_spdy_framer_|. |
2792 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_); | |
2793 // This condition implies that |kDefaultInitialRecvWindowSize| - | 2799 // This condition implies that |kDefaultInitialRecvWindowSize| - |
2794 // |session_recv_window_size_| doesn't overflow. | 2800 // |session_recv_window_size_| doesn't overflow. |
2795 DCHECK_GT(session_recv_window_size_, 0); | 2801 DCHECK_GE(session_max_recv_window_size_, session_recv_window_size_); |
2796 IncreaseRecvWindowSize( | 2802 DCHECK_GE(session_recv_window_size_, 0); |
2797 kDefaultInitialRecvWindowSize - session_recv_window_size_); | 2803 if (session_max_recv_window_size_ > session_recv_window_size_) { |
| 2804 IncreaseRecvWindowSize(session_max_recv_window_size_ - |
| 2805 session_recv_window_size_); |
| 2806 } |
2798 } | 2807 } |
2799 | 2808 |
2800 if (protocol_ <= kProtoSPDY31) { | 2809 if (protocol_ <= kProtoSPDY31) { |
2801 // Finally, notify the server about the settings they have | 2810 // Finally, notify the server about the settings they have |
2802 // previously told us to use when communicating with them (after | 2811 // previously told us to use when communicating with them (after |
2803 // applying them). | 2812 // applying them). |
2804 const SettingsMap& server_settings_map = | 2813 const SettingsMap& server_settings_map = |
2805 http_server_properties_->GetSpdySettings(host_port_pair()); | 2814 http_server_properties_->GetSpdySettings(host_port_pair()); |
2806 if (server_settings_map.empty()) | 2815 if (server_settings_map.empty()) |
2807 return; | 2816 return; |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3183 DCHECK_GE(delta_window_size, 1); | 3192 DCHECK_GE(delta_window_size, 1); |
3184 // Check for overflow. | 3193 // Check for overflow. |
3185 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); | 3194 DCHECK_LE(delta_window_size, kint32max - session_recv_window_size_); |
3186 | 3195 |
3187 session_recv_window_size_ += delta_window_size; | 3196 session_recv_window_size_ += delta_window_size; |
3188 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, | 3197 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW, |
3189 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 3198 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
3190 delta_window_size, session_recv_window_size_)); | 3199 delta_window_size, session_recv_window_size_)); |
3191 | 3200 |
3192 session_unacked_recv_window_bytes_ += delta_window_size; | 3201 session_unacked_recv_window_bytes_ += delta_window_size; |
3193 if (session_unacked_recv_window_bytes_ > | 3202 if (session_unacked_recv_window_bytes_ > session_max_recv_window_size_ / 2) { |
3194 GetInitialWindowSize(protocol_) / 2) { | |
3195 SendWindowUpdateFrame(kSessionFlowControlStreamId, | 3203 SendWindowUpdateFrame(kSessionFlowControlStreamId, |
3196 session_unacked_recv_window_bytes_, | 3204 session_unacked_recv_window_bytes_, |
3197 HIGHEST); | 3205 HIGHEST); |
3198 session_unacked_recv_window_bytes_ = 0; | 3206 session_unacked_recv_window_bytes_ = 0; |
3199 } | 3207 } |
3200 } | 3208 } |
3201 | 3209 |
3202 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { | 3210 void SpdySession::DecreaseRecvWindowSize(int32 delta_window_size) { |
3203 CHECK(in_io_loop_); | 3211 CHECK(in_io_loop_); |
3204 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); | 3212 DCHECK_EQ(flow_control_state_, FLOW_CONTROL_STREAM_AND_SESSION); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3267 if (!queue->empty()) { | 3275 if (!queue->empty()) { |
3268 SpdyStreamId stream_id = queue->front(); | 3276 SpdyStreamId stream_id = queue->front(); |
3269 queue->pop_front(); | 3277 queue->pop_front(); |
3270 return stream_id; | 3278 return stream_id; |
3271 } | 3279 } |
3272 } | 3280 } |
3273 return 0; | 3281 return 0; |
3274 } | 3282 } |
3275 | 3283 |
3276 } // namespace net | 3284 } // namespace net |
OLD | NEW |