| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const int kReadBufferSize = 8 * 1024; | 46 const int kReadBufferSize = 8 * 1024; |
| 47 const int kDefaultConnectionAtRiskOfLossSeconds = 10; | 47 const int kDefaultConnectionAtRiskOfLossSeconds = 10; |
| 48 const int kHungIntervalSeconds = 10; | 48 const int kHungIntervalSeconds = 10; |
| 49 | 49 |
| 50 // Always start at 1 for the first stream id. | 50 // Always start at 1 for the first stream id. |
| 51 const SpdyStreamId kFirstStreamId = 1; | 51 const SpdyStreamId kFirstStreamId = 1; |
| 52 | 52 |
| 53 // Minimum seconds that unclaimed pushed streams will be kept in memory. | 53 // Minimum seconds that unclaimed pushed streams will be kept in memory. |
| 54 const int kMinPushedStreamLifetimeSeconds = 300; | 54 const int kMinPushedStreamLifetimeSeconds = 300; |
| 55 | 55 |
| 56 int NPNToSpdyVersion(NextProto next_proto) { |
| 57 switch (next_proto) { |
| 58 case kProtoSPDY2: |
| 59 return kSpdyVersion2; |
| 60 case kProtoSPDY3: |
| 61 case kProtoSPDY31: |
| 62 return kSpdyVersion3; |
| 63 case kProtoSPDY4a1: |
| 64 return kSpdyVersion4; |
| 65 default: |
| 66 NOTREACHED(); |
| 67 } |
| 68 return kSpdyVersion2; |
| 69 } |
| 70 |
| 56 base::Value* NetLogSpdySynCallback(const SpdyHeaderBlock* headers, | 71 base::Value* NetLogSpdySynCallback(const SpdyHeaderBlock* headers, |
| 57 bool fin, | 72 bool fin, |
| 58 bool unidirectional, | 73 bool unidirectional, |
| 59 SpdyStreamId stream_id, | 74 SpdyStreamId stream_id, |
| 60 SpdyStreamId associated_stream, | 75 SpdyStreamId associated_stream, |
| 61 NetLog::LogLevel /* log_level */) { | 76 NetLog::LogLevel /* log_level */) { |
| 62 base::DictionaryValue* dict = new base::DictionaryValue(); | 77 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 63 base::ListValue* headers_list = new base::ListValue(); | 78 base::ListValue* headers_list = new base::ListValue(); |
| 64 for (SpdyHeaderBlock::const_iterator it = headers->begin(); | 79 for (SpdyHeaderBlock::const_iterator it = headers->begin(); |
| 65 it != headers->end(); ++it) { | 80 it != headers->end(); ++it) { |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 412 } |
| 398 | 413 |
| 399 SSLClientSocket* ssl_socket = GetSSLClientSocket(); | 414 SSLClientSocket* ssl_socket = GetSSLClientSocket(); |
| 400 if (ssl_socket && ssl_socket->WasChannelIDSent()) { | 415 if (ssl_socket && ssl_socket->WasChannelIDSent()) { |
| 401 // According to the SPDY spec, the credential associated with the TLS | 416 // According to the SPDY spec, the credential associated with the TLS |
| 402 // connection is stored in slot[1]. | 417 // connection is stored in slot[1]. |
| 403 credential_state_.SetHasCredential(GURL("https://" + | 418 credential_state_.SetHasCredential(GURL("https://" + |
| 404 host_port_pair().ToString())); | 419 host_port_pair().ToString())); |
| 405 } | 420 } |
| 406 | 421 |
| 407 DCHECK_GE(protocol, kProtoSPDY2); | 422 if (protocol >= kProtoSPDY4a1) { |
| 408 DCHECK_LE(protocol, kProtoSPDY31); | |
| 409 int version = (protocol >= kProtoSPDY3) ? kSpdyVersion3 : kSpdyVersion2; | |
| 410 if (protocol >= kProtoSPDY31) { | |
| 411 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; | 423 flow_control_state_ = FLOW_CONTROL_STREAM_AND_SESSION; |
| 412 session_send_window_size_ = kSpdySessionInitialWindowSize; | 424 session_send_window_size_ = kSpdySessionInitialWindowSize; |
| 413 session_recv_window_size_ = kSpdySessionInitialWindowSize; | 425 session_recv_window_size_ = kSpdySessionInitialWindowSize; |
| 414 } else if (protocol >= kProtoSPDY3) { | 426 } else if (protocol >= kProtoSPDY3) { |
| 415 flow_control_state_ = FLOW_CONTROL_STREAM; | 427 flow_control_state_ = FLOW_CONTROL_STREAM; |
| 416 } else { | 428 } else { |
| 417 flow_control_state_ = FLOW_CONTROL_NONE; | 429 flow_control_state_ = FLOW_CONTROL_NONE; |
| 418 } | 430 } |
| 419 | 431 |
| 420 buffered_spdy_framer_.reset(new BufferedSpdyFramer(version, | 432 buffered_spdy_framer_.reset( |
| 421 enable_compression_)); | 433 new BufferedSpdyFramer(NPNToSpdyVersion(protocol), enable_compression_)); |
| 422 buffered_spdy_framer_->set_visitor(this); | 434 buffered_spdy_framer_->set_visitor(this); |
| 423 SendInitialSettings(); | 435 SendInitialSettings(); |
| 424 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol, kProtoMaximumVersion); | 436 UMA_HISTOGRAM_ENUMERATION("Net.SpdyVersion", protocol, kProtoMaximumVersion); |
| 425 | 437 |
| 426 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { | 438 if (flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION) { |
| 427 // Bump up the receive window size to the real initial value. This | 439 // Bump up the receive window size to the real initial value. This |
| 428 // has to go here since the WINDOW_UPDATE frame sent by | 440 // has to go here since the WINDOW_UPDATE frame sent by |
| 429 // IncreaseRecvWindowSize() call uses |buffered_spdy_framer_|. | 441 // IncreaseRecvWindowSize() call uses |buffered_spdy_framer_|. |
| 430 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_); | 442 DCHECK_GT(kDefaultInitialRecvWindowSize, session_recv_window_size_); |
| 431 // This condition implies that |kDefaultInitialRecvWindowSize| - | 443 // This condition implies that |kDefaultInitialRecvWindowSize| - |
| (...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 } | 2261 } |
| 2250 | 2262 |
| 2251 session_recv_window_size_ -= delta_window_size; | 2263 session_recv_window_size_ -= delta_window_size; |
| 2252 net_log_.AddEvent( | 2264 net_log_.AddEvent( |
| 2253 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, | 2265 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, |
| 2254 base::Bind(&NetLogSpdySessionWindowUpdateCallback, | 2266 base::Bind(&NetLogSpdySessionWindowUpdateCallback, |
| 2255 -delta_window_size, session_recv_window_size_)); | 2267 -delta_window_size, session_recv_window_size_)); |
| 2256 } | 2268 } |
| 2257 | 2269 |
| 2258 } // namespace net | 2270 } // namespace net |
| OLD | NEW |