| 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 #ifndef NET_SPDY_SPDY_SESSION_H_ | 5 #ifndef NET_SPDY_SPDY_SESSION_H_ |
| 6 #define NET_SPDY_SPDY_SESSION_H_ | 6 #define NET_SPDY_SPDY_SESSION_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // sends a SETTINGS frame with a different value. | 51 // sends a SETTINGS frame with a different value. |
| 52 const size_t kInitialMaxConcurrentStreams = 100; | 52 const size_t kInitialMaxConcurrentStreams = 100; |
| 53 | 53 |
| 54 // Specifies the maxiumum concurrent streams server could send (via push). | 54 // Specifies the maxiumum concurrent streams server could send (via push). |
| 55 const int kMaxConcurrentPushedStreams = 1000; | 55 const int kMaxConcurrentPushedStreams = 1000; |
| 56 | 56 |
| 57 // Specifies the maximum number of bytes to read synchronously before | 57 // Specifies the maximum number of bytes to read synchronously before |
| 58 // yielding. | 58 // yielding. |
| 59 const int kMaxReadBytesWithoutYielding = 32 * 1024; | 59 const int kMaxReadBytesWithoutYielding = 32 * 1024; |
| 60 | 60 |
| 61 // The initial receive window size for both streams and sessions. | |
| 62 const int32 kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB | |
| 63 | |
| 64 // First and last valid stream IDs. As we always act as the client, | 61 // First and last valid stream IDs. As we always act as the client, |
| 65 // start at 1 for the first stream id. | 62 // start at 1 for the first stream id. |
| 66 const SpdyStreamId kFirstStreamId = 1; | 63 const SpdyStreamId kFirstStreamId = 1; |
| 67 const SpdyStreamId kLastStreamId = 0x7fffffff; | 64 const SpdyStreamId kLastStreamId = 0x7fffffff; |
| 68 | 65 |
| 69 class BoundNetLog; | 66 class BoundNetLog; |
| 70 struct LoadTimingInfo; | 67 struct LoadTimingInfo; |
| 71 class SpdyStream; | 68 class SpdyStream; |
| 72 class SSLInfo; | 69 class SSLInfo; |
| 73 class TransportSecurityState; | 70 class TransportSecurityState; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log | 235 // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log |
| 239 // network events to. | 236 // network events to. |
| 240 SpdySession(const SpdySessionKey& spdy_session_key, | 237 SpdySession(const SpdySessionKey& spdy_session_key, |
| 241 const base::WeakPtr<HttpServerProperties>& http_server_properties, | 238 const base::WeakPtr<HttpServerProperties>& http_server_properties, |
| 242 TransportSecurityState* transport_security_state, | 239 TransportSecurityState* transport_security_state, |
| 243 bool verify_domain_authentication, | 240 bool verify_domain_authentication, |
| 244 bool enable_sending_initial_data, | 241 bool enable_sending_initial_data, |
| 245 bool enable_compression, | 242 bool enable_compression, |
| 246 bool enable_ping_based_connection_checking, | 243 bool enable_ping_based_connection_checking, |
| 247 NextProto default_protocol, | 244 NextProto default_protocol, |
| 248 size_t stream_initial_recv_window_size, | 245 size_t session_max_recv_window_size, |
| 246 size_t stream_max_recv_window_size, |
| 249 size_t initial_max_concurrent_streams, | 247 size_t initial_max_concurrent_streams, |
| 250 size_t max_concurrent_streams_limit, | 248 size_t max_concurrent_streams_limit, |
| 251 TimeFunc time_func, | 249 TimeFunc time_func, |
| 252 const HostPortPair& trusted_spdy_proxy, | 250 const HostPortPair& trusted_spdy_proxy, |
| 253 NetLog* net_log); | 251 NetLog* net_log); |
| 254 | 252 |
| 255 ~SpdySession() override; | 253 ~SpdySession() override; |
| 256 | 254 |
| 257 const HostPortPair& host_port_pair() const { | 255 const HostPortPair& host_port_pair() const { |
| 258 return spdy_session_key_.host_port_proxy_pair().first; | 256 return spdy_session_key_.host_port_proxy_pair().first; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // Returns the (version-dependent) flow control state. | 454 // Returns the (version-dependent) flow control state. |
| 457 FlowControlState flow_control_state() const { | 455 FlowControlState flow_control_state() const { |
| 458 return flow_control_state_; | 456 return flow_control_state_; |
| 459 } | 457 } |
| 460 | 458 |
| 461 // Returns the current |stream_initial_send_window_size_|. | 459 // Returns the current |stream_initial_send_window_size_|. |
| 462 int32 stream_initial_send_window_size() const { | 460 int32 stream_initial_send_window_size() const { |
| 463 return stream_initial_send_window_size_; | 461 return stream_initial_send_window_size_; |
| 464 } | 462 } |
| 465 | 463 |
| 466 // Returns the current |stream_initial_recv_window_size_|. | 464 // Returns the current |stream_max_recv_window_size_|. |
| 467 int32 stream_initial_recv_window_size() const { | 465 int32 stream_max_recv_window_size() const { |
| 468 return stream_initial_recv_window_size_; | 466 return stream_max_recv_window_size_; |
| 469 } | 467 } |
| 470 | 468 |
| 471 // Returns true if no stream in the session can send data due to | 469 // Returns true if no stream in the session can send data due to |
| 472 // session flow control. | 470 // session flow control. |
| 473 bool IsSendStalled() const { | 471 bool IsSendStalled() const { |
| 474 return | 472 return |
| 475 flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION && | 473 flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION && |
| 476 session_send_window_size_ == 0; | 474 session_send_window_size_ == 0; |
| 477 } | 475 } |
| 478 | 476 |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 // Indicate if we have already scheduled a delayed task to check the ping | 1103 // Indicate if we have already scheduled a delayed task to check the ping |
| 1106 // status. | 1104 // status. |
| 1107 bool check_ping_status_pending_; | 1105 bool check_ping_status_pending_; |
| 1108 | 1106 |
| 1109 // Whether to send the (HTTP/2) connection header prefix. | 1107 // Whether to send the (HTTP/2) connection header prefix. |
| 1110 bool send_connection_header_prefix_; | 1108 bool send_connection_header_prefix_; |
| 1111 | 1109 |
| 1112 // The (version-dependent) flow control state. | 1110 // The (version-dependent) flow control state. |
| 1113 FlowControlState flow_control_state_; | 1111 FlowControlState flow_control_state_; |
| 1114 | 1112 |
| 1113 // Current send window size. Zero unless session flow control is turned on. |
| 1114 int32 session_send_window_size_; |
| 1115 |
| 1116 // Maximum receive window size. Each time a WINDOW_UPDATE is sent, it |
| 1117 // restores the receive window size to this value. Zero unless session flow |
| 1118 // control is turned on. |
| 1119 int32 session_max_recv_window_size_; |
| 1120 |
| 1121 // Sum of |session_unacked_recv_window_bytes_| and current receive window |
| 1122 // size. Zero unless session flow control is turned on. |
| 1123 // TODO(bnc): Rename or change semantics so that |window_size_| is actual |
| 1124 // window size. |
| 1125 int32 session_recv_window_size_; |
| 1126 |
| 1127 // When bytes are consumed, SpdyIOBuffer destructor calls back to SpdySession, |
| 1128 // and this member keeps count of them until the corresponding WINDOW_UPDATEs |
| 1129 // are sent. Zero unless session flow control is turned on. |
| 1130 int32 session_unacked_recv_window_bytes_; |
| 1131 |
| 1115 // Initial send window size for this session's streams. Can be | 1132 // Initial send window size for this session's streams. Can be |
| 1116 // changed by an arriving SETTINGS frame. Newly created streams use | 1133 // changed by an arriving SETTINGS frame. Newly created streams use |
| 1117 // this value for the initial send window size. | 1134 // this value for the initial send window size. |
| 1118 int32 stream_initial_send_window_size_; | 1135 int32 stream_initial_send_window_size_; |
| 1119 | 1136 |
| 1120 // Initial receive window size for this session's streams. There are | 1137 // Initial receive window size for this session's streams. There are |
| 1121 // plans to add a command line switch that would cause a SETTINGS | 1138 // plans to add a command line switch that would cause a SETTINGS |
| 1122 // frame with window size announcement to be sent on startup. Newly | 1139 // frame with window size announcement to be sent on startup. Newly |
| 1123 // created streams will use this value for the initial receive | 1140 // created streams will use this value for the initial receive |
| 1124 // window size. | 1141 // window size. |
| 1125 int32 stream_initial_recv_window_size_; | 1142 int32 stream_max_recv_window_size_; |
| 1126 | |
| 1127 // Session flow control variables. All zero unless session flow | |
| 1128 // control is turned on. | |
| 1129 int32 session_send_window_size_; | |
| 1130 int32 session_recv_window_size_; | |
| 1131 int32 session_unacked_recv_window_bytes_; | |
| 1132 | 1143 |
| 1133 // A queue of stream IDs that have been send-stalled at some point | 1144 // A queue of stream IDs that have been send-stalled at some point |
| 1134 // in the past. | 1145 // in the past. |
| 1135 std::deque<SpdyStreamId> stream_send_unstall_queue_[NUM_PRIORITIES]; | 1146 std::deque<SpdyStreamId> stream_send_unstall_queue_[NUM_PRIORITIES]; |
| 1136 | 1147 |
| 1137 BoundNetLog net_log_; | 1148 BoundNetLog net_log_; |
| 1138 | 1149 |
| 1139 // Outside of tests, these should always be true. | 1150 // Outside of tests, these should always be true. |
| 1140 bool verify_domain_authentication_; | 1151 bool verify_domain_authentication_; |
| 1141 bool enable_sending_initial_data_; | 1152 bool enable_sending_initial_data_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 // Used for posting asynchronous IO tasks. We use this even though | 1188 // Used for posting asynchronous IO tasks. We use this even though |
| 1178 // SpdySession is refcounted because we don't need to keep the SpdySession | 1189 // SpdySession is refcounted because we don't need to keep the SpdySession |
| 1179 // alive if the last reference is within a RunnableMethod. Just revoke the | 1190 // alive if the last reference is within a RunnableMethod. Just revoke the |
| 1180 // method. | 1191 // method. |
| 1181 base::WeakPtrFactory<SpdySession> weak_factory_; | 1192 base::WeakPtrFactory<SpdySession> weak_factory_; |
| 1182 }; | 1193 }; |
| 1183 | 1194 |
| 1184 } // namespace net | 1195 } // namespace net |
| 1185 | 1196 |
| 1186 #endif // NET_SPDY_SPDY_SESSION_H_ | 1197 #endif // NET_SPDY_SPDY_SESSION_H_ |
| OLD | NEW |