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 <map> | 7 #include <map> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 const HostPortPair& trusted_spdy_proxy, | 342 const HostPortPair& trusted_spdy_proxy, |
343 NetLog* net_log) | 343 NetLog* net_log) |
344 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 344 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
345 host_port_proxy_pair_(host_port_proxy_pair), | 345 host_port_proxy_pair_(host_port_proxy_pair), |
346 spdy_session_pool_(spdy_session_pool), | 346 spdy_session_pool_(spdy_session_pool), |
347 http_server_properties_(http_server_properties), | 347 http_server_properties_(http_server_properties), |
348 connection_(new ClientSocketHandle), | 348 connection_(new ClientSocketHandle), |
349 read_buffer_(new IOBuffer(kReadBufferSize)), | 349 read_buffer_(new IOBuffer(kReadBufferSize)), |
350 read_pending_(false), | 350 read_pending_(false), |
351 stream_hi_water_mark_(1), // Always start at 1 for the first stream id. | 351 stream_hi_water_mark_(1), // Always start at 1 for the first stream id. |
352 last_syn_stream_id_(0), | |
352 write_pending_(false), | 353 write_pending_(false), |
353 delayed_write_pending_(false), | 354 delayed_write_pending_(false), |
354 is_secure_(false), | 355 is_secure_(false), |
355 certificate_error_code_(OK), | 356 certificate_error_code_(OK), |
356 error_(OK), | 357 error_(OK), |
357 state_(IDLE), | 358 state_(IDLE), |
358 max_concurrent_streams_(g_init_max_concurrent_streams), | 359 max_concurrent_streams_(g_init_max_concurrent_streams), |
359 streams_initiated_count_(0), | 360 streams_initiated_count_(0), |
360 streams_pushed_count_(0), | 361 streams_pushed_count_(0), |
361 streams_pushed_and_claimed_count_(0), | 362 streams_pushed_and_claimed_count_(0), |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion()), | 669 ConvertRequestPriorityToSpdyPriority(priority, GetProtocolVersion()), |
669 credential_slot, flags, false, headers.get())); | 670 credential_slot, flags, false, headers.get())); |
670 QueueFrame(syn_frame.get(), priority, stream); | 671 QueueFrame(syn_frame.get(), priority, stream); |
671 | 672 |
672 base::StatsCounter spdy_requests("spdy.requests"); | 673 base::StatsCounter spdy_requests("spdy.requests"); |
673 spdy_requests.Increment(); | 674 spdy_requests.Increment(); |
674 streams_initiated_count_++; | 675 streams_initiated_count_++; |
675 | 676 |
676 if (net_log().IsLoggingAllEvents()) { | 677 if (net_log().IsLoggingAllEvents()) { |
677 net_log().AddEvent( | 678 net_log().AddEvent( |
678 NetLog::TYPE_SPDY_SESSION_SYN_STREAM, | 679 NetLog::TYPE_SPDY_SESSION_SYN_STREAM, |
willchan no longer on Chromium
2012/05/15 13:54:15
This is going to be off now...right? Maybe we just
Ryan Hamilton
2012/05/15 16:41:11
Oh, right. I had though about this, but apparentl
| |
679 make_scoped_refptr( | 680 make_scoped_refptr( |
680 new NetLogSpdySynParameter(headers, flags, stream_id, 0))); | 681 new NetLogSpdySynParameter(headers, flags, stream_id, 0))); |
681 } | 682 } |
682 | 683 |
683 // Some servers don't like too many pings, so we limit our current sending to | 684 // Some servers don't like too many pings, so we limit our current sending to |
684 // no more than two pings for any syn frame or data frame sent. To do this, | 685 // no more than two pings for any syn frame or data frame sent. To do this, |
685 // we avoid ever setting this to true unless we send a syn (which we have just | 686 // we avoid ever setting this to true unless we send a syn (which we have just |
686 // done) or data frame. This approach may change over time as servers change | 687 // done) or data frame. This approach may change over time as servers change |
687 // their responses to pings. | 688 // their responses to pings. |
688 need_to_send_ping_ = true; | 689 need_to_send_ping_ = true; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1028 while (in_flight_write_.buffer() || !queue_.empty()) { | 1029 while (in_flight_write_.buffer() || !queue_.empty()) { |
1029 if (!in_flight_write_.buffer()) { | 1030 if (!in_flight_write_.buffer()) { |
1030 // Grab the next SpdyFrame to send. | 1031 // Grab the next SpdyFrame to send. |
1031 SpdyIOBuffer next_buffer = queue_.top(); | 1032 SpdyIOBuffer next_buffer = queue_.top(); |
1032 queue_.pop(); | 1033 queue_.pop(); |
1033 | 1034 |
1034 // We've deferred compression until just before we write it to the socket, | 1035 // We've deferred compression until just before we write it to the socket, |
1035 // which is now. At this time, we don't compress our data frames. | 1036 // which is now. At this time, we don't compress our data frames. |
1036 SpdyFrame uncompressed_frame(next_buffer.buffer()->data(), false); | 1037 SpdyFrame uncompressed_frame(next_buffer.buffer()->data(), false); |
1037 size_t size; | 1038 size_t size; |
1039 if (uncompressed_frame.is_control_frame()) { | |
1040 SpdyControlFrame control_frame(next_buffer.buffer()->data(), false); | |
1041 if (control_frame.type() == SYN_STREAM) { | |
1042 SpdySynStreamControlFrame syn_stream(next_buffer.buffer()->data(), | |
1043 false); | |
1044 SpdyStreamId id = syn_stream.stream_id(); | |
1045 DCHECK(IsStreamActive(id)); | |
1046 if (id < last_syn_stream_id_) { | |
1047 // need to play some games to change the stream_id | |
1048 scoped_refptr<SpdyStream> stream = active_streams_[id]; | |
1049 active_streams_.erase(id); | |
1050 id = GetNewStreamId(); | |
1051 syn_stream.set_stream_id(id); | |
1052 stream->set_stream_id(id); | |
1053 ActivateStream(stream); | |
1054 } | |
1055 last_syn_stream_id_ = id; | |
1056 } | |
1057 } | |
1038 if (buffered_spdy_framer_->IsCompressible(uncompressed_frame)) { | 1058 if (buffered_spdy_framer_->IsCompressible(uncompressed_frame)) { |
1039 DCHECK(uncompressed_frame.is_control_frame()); | 1059 DCHECK(uncompressed_frame.is_control_frame()); |
1040 scoped_ptr<SpdyFrame> compressed_frame( | 1060 scoped_ptr<SpdyFrame> compressed_frame( |
1041 buffered_spdy_framer_->CompressControlFrame( | 1061 buffered_spdy_framer_->CompressControlFrame( |
1042 reinterpret_cast<const SpdyControlFrame&>(uncompressed_frame))); | 1062 reinterpret_cast<const SpdyControlFrame&>(uncompressed_frame))); |
1043 if (!compressed_frame.get()) { | 1063 if (!compressed_frame.get()) { |
1044 RecordProtocolErrorHistogram( | 1064 RecordProtocolErrorHistogram( |
1045 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE); | 1065 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE); |
1046 CloseSessionOnError( | 1066 CloseSessionOnError( |
1047 net::ERR_SPDY_PROTOCOL_ERROR, true, "SPDY Compression failure."); | 1067 net::ERR_SPDY_PROTOCOL_ERROR, true, "SPDY Compression failure."); |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1982 SSLClientSocket* SpdySession::GetSSLClientSocket() const { | 2002 SSLClientSocket* SpdySession::GetSSLClientSocket() const { |
1983 if (!is_secure_) | 2003 if (!is_secure_) |
1984 return NULL; | 2004 return NULL; |
1985 SSLClientSocket* ssl_socket = | 2005 SSLClientSocket* ssl_socket = |
1986 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 2006 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
1987 DCHECK(ssl_socket); | 2007 DCHECK(ssl_socket); |
1988 return ssl_socket; | 2008 return ssl_socket; |
1989 } | 2009 } |
1990 | 2010 |
1991 } // namespace net | 2011 } // namespace net |
OLD | NEW |