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 <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 620 |
621 return true; | 621 return true; |
622 } | 622 } |
623 | 623 |
624 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, | 624 SpdySession::SpdySession(const SpdySessionKey& spdy_session_key, |
625 HttpServerProperties* http_server_properties, | 625 HttpServerProperties* http_server_properties, |
626 TransportSecurityState* transport_security_state, | 626 TransportSecurityState* transport_security_state, |
627 bool verify_domain_authentication, | 627 bool verify_domain_authentication, |
628 bool enable_sending_initial_data, | 628 bool enable_sending_initial_data, |
629 bool enable_ping_based_connection_checking, | 629 bool enable_ping_based_connection_checking, |
630 bool enable_priority_dependencies, | |
631 size_t session_max_recv_window_size, | 630 size_t session_max_recv_window_size, |
632 size_t stream_max_recv_window_size, | 631 size_t stream_max_recv_window_size, |
633 TimeFunc time_func, | 632 TimeFunc time_func, |
634 ProxyDelegate* proxy_delegate, | 633 ProxyDelegate* proxy_delegate, |
635 NetLog* net_log) | 634 NetLog* net_log) |
636 : in_io_loop_(false), | 635 : in_io_loop_(false), |
637 spdy_session_key_(spdy_session_key), | 636 spdy_session_key_(spdy_session_key), |
638 pool_(NULL), | 637 pool_(NULL), |
639 http_server_properties_(http_server_properties), | 638 http_server_properties_(http_server_properties), |
640 transport_security_state_(transport_security_state), | 639 transport_security_state_(transport_security_state), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP2_SESSION)), | 675 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP2_SESSION)), |
677 verify_domain_authentication_(verify_domain_authentication), | 676 verify_domain_authentication_(verify_domain_authentication), |
678 enable_sending_initial_data_(enable_sending_initial_data), | 677 enable_sending_initial_data_(enable_sending_initial_data), |
679 enable_ping_based_connection_checking_( | 678 enable_ping_based_connection_checking_( |
680 enable_ping_based_connection_checking), | 679 enable_ping_based_connection_checking), |
681 connection_at_risk_of_loss_time_( | 680 connection_at_risk_of_loss_time_( |
682 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), | 681 base::TimeDelta::FromSeconds(kDefaultConnectionAtRiskOfLossSeconds)), |
683 hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), | 682 hung_interval_(base::TimeDelta::FromSeconds(kHungIntervalSeconds)), |
684 proxy_delegate_(proxy_delegate), | 683 proxy_delegate_(proxy_delegate), |
685 time_func_(time_func), | 684 time_func_(time_func), |
686 priority_dependencies_enabled_(enable_priority_dependencies), | |
687 weak_factory_(this) { | 685 weak_factory_(this) { |
688 net_log_.BeginEvent( | 686 net_log_.BeginEvent( |
689 NetLog::TYPE_HTTP2_SESSION, | 687 NetLog::TYPE_HTTP2_SESSION, |
690 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair())); | 688 base::Bind(&NetLogSpdySessionCallback, &host_port_proxy_pair())); |
691 next_unclaimed_push_stream_sweep_time_ = time_func_() + | 689 next_unclaimed_push_stream_sweep_time_ = time_func_() + |
692 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); | 690 base::TimeDelta::FromSeconds(kMinPushedStreamLifetimeSeconds); |
693 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. | 691 // TODO(mbelshe): consider randomization of the stream_hi_water_mark. |
694 } | 692 } |
695 | 693 |
696 SpdySession::~SpdySession() { | 694 SpdySession::~SpdySession() { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 | 1009 |
1012 DCHECK(buffered_spdy_framer_.get()); | 1010 DCHECK(buffered_spdy_framer_.get()); |
1013 SpdyPriority spdy_priority = ConvertRequestPriorityToSpdyPriority(priority); | 1011 SpdyPriority spdy_priority = ConvertRequestPriorityToSpdyPriority(priority); |
1014 | 1012 |
1015 std::unique_ptr<SpdySerializedFrame> syn_frame; | 1013 std::unique_ptr<SpdySerializedFrame> syn_frame; |
1016 bool has_priority = true; | 1014 bool has_priority = true; |
1017 int weight = Spdy3PriorityToHttp2Weight(spdy_priority); | 1015 int weight = Spdy3PriorityToHttp2Weight(spdy_priority); |
1018 SpdyStreamId dependent_stream_id = 0; | 1016 SpdyStreamId dependent_stream_id = 0; |
1019 bool exclusive = false; | 1017 bool exclusive = false; |
1020 | 1018 |
1021 if (priority_dependencies_enabled_) { | 1019 priority_dependency_state_.OnStreamSynSent(stream_id, spdy_priority, |
1022 priority_dependency_state_.OnStreamSynSent( | 1020 &dependent_stream_id, &exclusive); |
1023 stream_id, spdy_priority, &dependent_stream_id, &exclusive); | |
1024 } | |
1025 | 1021 |
1026 if (net_log().IsCapturing()) { | 1022 if (net_log().IsCapturing()) { |
1027 net_log().AddEvent( | 1023 net_log().AddEvent( |
1028 NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS, | 1024 NetLog::TYPE_HTTP2_SESSION_SEND_HEADERS, |
1029 base::Bind(&NetLogSpdyHeadersSentCallback, &block, | 1025 base::Bind(&NetLogSpdyHeadersSentCallback, &block, |
1030 (flags & CONTROL_FLAG_FIN) != 0, stream_id, has_priority, | 1026 (flags & CONTROL_FLAG_FIN) != 0, stream_id, has_priority, |
1031 weight, dependent_stream_id, exclusive)); | 1027 weight, dependent_stream_id, exclusive)); |
1032 } | 1028 } |
1033 | 1029 |
1034 SpdyHeadersIR headers(stream_id, std::move(block)); | 1030 SpdyHeadersIR headers(stream_id, std::move(block)); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 return LOAD_STATE_IDLE; | 1202 return LOAD_STATE_IDLE; |
1207 } | 1203 } |
1208 | 1204 |
1209 void SpdySession::CloseActiveStreamIterator(ActiveStreamMap::iterator it, | 1205 void SpdySession::CloseActiveStreamIterator(ActiveStreamMap::iterator it, |
1210 int status) { | 1206 int status) { |
1211 // TODO(mbelshe): We should send a RST_STREAM control frame here | 1207 // TODO(mbelshe): We should send a RST_STREAM control frame here |
1212 // so that the server can cancel a large send. | 1208 // so that the server can cancel a large send. |
1213 | 1209 |
1214 std::unique_ptr<SpdyStream> owned_stream(it->second.stream); | 1210 std::unique_ptr<SpdyStream> owned_stream(it->second.stream); |
1215 active_streams_.erase(it); | 1211 active_streams_.erase(it); |
1216 if (priority_dependencies_enabled_) | 1212 priority_dependency_state_.OnStreamDestruction(owned_stream->stream_id()); |
1217 priority_dependency_state_.OnStreamDestruction(owned_stream->stream_id()); | |
1218 | 1213 |
1219 // TODO(akalin): When SpdyStream was ref-counted (and | 1214 // TODO(akalin): When SpdyStream was ref-counted (and |
1220 // |unclaimed_pushed_streams_| held scoped_refptr<SpdyStream>), this | 1215 // |unclaimed_pushed_streams_| held scoped_refptr<SpdyStream>), this |
1221 // was only done when status was not OK. This meant that pushed | 1216 // was only done when status was not OK. This meant that pushed |
1222 // streams can still be claimed after they're closed. This is | 1217 // streams can still be claimed after they're closed. This is |
1223 // probably something that we still want to support, although server | 1218 // probably something that we still want to support, although server |
1224 // push is hardly used. Write tests for this and fix this. (See | 1219 // push is hardly used. Write tests for this and fix this. (See |
1225 // http://crbug.com/261712 .) | 1220 // http://crbug.com/261712 .) |
1226 if (owned_stream->type() == SPDY_PUSH_STREAM) { | 1221 if (owned_stream->type() == SPDY_PUSH_STREAM) { |
1227 unclaimed_pushed_streams_.erase(owned_stream->url()); | 1222 unclaimed_pushed_streams_.erase(owned_stream->url()); |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 if (!queue->empty()) { | 3150 if (!queue->empty()) { |
3156 SpdyStreamId stream_id = queue->front(); | 3151 SpdyStreamId stream_id = queue->front(); |
3157 queue->pop_front(); | 3152 queue->pop_front(); |
3158 return stream_id; | 3153 return stream_id; |
3159 } | 3154 } |
3160 } | 3155 } |
3161 return 0; | 3156 return 0; |
3162 } | 3157 } |
3163 | 3158 |
3164 } // namespace net | 3159 } // namespace net |
OLD | NEW |