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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 SSLInfo ssl_info; | 827 SSLInfo ssl_info; |
828 if (!GetSSLInfo(&ssl_info)) | 828 if (!GetSSLInfo(&ssl_info)) |
829 return true; // This is not a secure session, so all domains are okay. | 829 return true; // This is not a secure session, so all domains are okay. |
830 | 830 |
831 return CanPool(transport_security_state_, ssl_info, | 831 return CanPool(transport_security_state_, ssl_info, |
832 host_port_pair().host(), domain); | 832 host_port_pair().host(), domain); |
833 } | 833 } |
834 | 834 |
835 int SpdySession::GetPushStream(const GURL& url, | 835 int SpdySession::GetPushStream(const GURL& url, |
836 RequestPriority priority, | 836 RequestPriority priority, |
837 base::WeakPtr<SpdyStream>* stream, | 837 SpdyStream** stream, |
838 const NetLogWithSource& stream_net_log) { | 838 const NetLogWithSource& stream_net_log) { |
839 CHECK(!in_io_loop_); | 839 CHECK(!in_io_loop_); |
840 | 840 |
841 stream->reset(); | |
842 | |
843 if (availability_state_ == STATE_DRAINING) | 841 if (availability_state_ == STATE_DRAINING) |
xunjieli
2017/01/20 02:57:20
I think we need to keep the original logic to rese
Bence
2017/01/20 15:53:13
Done. I moved it to the if branch. BTW the DCHEC
xunjieli
2017/01/20 15:57:23
Acknowledged.
| |
844 return ERR_CONNECTION_CLOSED; | 842 return ERR_CONNECTION_CLOSED; |
845 | 843 |
846 *stream = GetActivePushStream(url); | 844 *stream = GetActivePushStream(url); |
847 if (*stream) { | 845 if (*stream) { |
848 DCHECK_LT(streams_pushed_and_claimed_count_, streams_pushed_count_); | 846 DCHECK_LT(streams_pushed_and_claimed_count_, streams_pushed_count_); |
849 streams_pushed_and_claimed_count_++; | 847 streams_pushed_and_claimed_count_++; |
850 | 848 |
851 // If the stream is still open, update its priority to match | 849 // If the stream is still open, update its priority to match |
852 // the priority of the matching request. | 850 // the priority of the matching request. |
853 if (!(*stream)->IsClosed() && (*stream)->priority() != priority) { | 851 if (!(*stream)->IsClosed() && (*stream)->priority() != priority) { |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1978 } | 1976 } |
1979 | 1977 |
1980 SpdyStreamId SpdySession::GetStreamIdForPush(const GURL& url) { | 1978 SpdyStreamId SpdySession::GetStreamIdForPush(const GURL& url) { |
1981 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = | 1979 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = |
1982 unclaimed_pushed_streams_.find(url); | 1980 unclaimed_pushed_streams_.find(url); |
1983 if (unclaimed_it == unclaimed_pushed_streams_.end()) | 1981 if (unclaimed_it == unclaimed_pushed_streams_.end()) |
1984 return 0; | 1982 return 0; |
1985 return unclaimed_it->second.stream_id; | 1983 return unclaimed_it->second.stream_id; |
1986 } | 1984 } |
1987 | 1985 |
1988 base::WeakPtr<SpdyStream> SpdySession::GetActivePushStream(const GURL& url) { | 1986 SpdyStream* SpdySession::GetActivePushStream(const GURL& url) { |
1989 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = | 1987 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = |
1990 unclaimed_pushed_streams_.find(url); | 1988 unclaimed_pushed_streams_.find(url); |
1991 if (unclaimed_it == unclaimed_pushed_streams_.end()) | 1989 if (unclaimed_it == unclaimed_pushed_streams_.end()) |
1992 return base::WeakPtr<SpdyStream>(); | 1990 return nullptr; |
1993 | 1991 |
1994 SpdyStreamId stream_id = unclaimed_it->second.stream_id; | 1992 SpdyStreamId stream_id = unclaimed_it->second.stream_id; |
1995 unclaimed_pushed_streams_.erase(unclaimed_it); | 1993 unclaimed_pushed_streams_.erase(unclaimed_it); |
1996 | 1994 |
1997 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); | 1995 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); |
1998 if (active_it == active_streams_.end()) { | 1996 if (active_it == active_streams_.end()) { |
1999 NOTREACHED(); | 1997 NOTREACHED(); |
2000 return base::WeakPtr<SpdyStream>(); | 1998 return nullptr; |
2001 } | 1999 } |
2002 | 2000 |
2003 net_log_.AddEvent(NetLogEventType::HTTP2_STREAM_ADOPTED_PUSH_STREAM, | 2001 net_log_.AddEvent(NetLogEventType::HTTP2_STREAM_ADOPTED_PUSH_STREAM, |
2004 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, | 2002 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, |
2005 active_it->second->stream_id(), &url)); | 2003 active_it->second->stream_id(), &url)); |
2006 return active_it->second->GetWeakPtr(); | 2004 return active_it->second; |
2007 } | 2005 } |
2008 | 2006 |
2009 url::SchemeHostPort SpdySession::GetServer() { | 2007 url::SchemeHostPort SpdySession::GetServer() { |
2010 return url::SchemeHostPort(is_secure_ ? "https" : "http", | 2008 return url::SchemeHostPort(is_secure_ ? "https" : "http", |
2011 host_port_pair().host(), host_port_pair().port()); | 2009 host_port_pair().host(), host_port_pair().port()); |
2012 } | 2010 } |
2013 | 2011 |
2014 bool SpdySession::GetRemoteEndpoint(IPEndPoint* endpoint) { | 2012 bool SpdySession::GetRemoteEndpoint(IPEndPoint* endpoint) { |
2015 return GetPeerAddress(endpoint) == OK; | 2013 return GetPeerAddress(endpoint) == OK; |
2016 } | 2014 } |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3118 if (!queue->empty()) { | 3116 if (!queue->empty()) { |
3119 SpdyStreamId stream_id = queue->front(); | 3117 SpdyStreamId stream_id = queue->front(); |
3120 queue->pop_front(); | 3118 queue->pop_front(); |
3121 return stream_id; | 3119 return stream_id; |
3122 } | 3120 } |
3123 } | 3121 } |
3124 return 0; | 3122 return 0; |
3125 } | 3123 } |
3126 | 3124 |
3127 } // namespace net | 3125 } // namespace net |
OLD | NEW |