| 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(); | 841 if (availability_state_ == STATE_DRAINING) { |
| 842 | 842 *stream = nullptr; |
| 843 if (availability_state_ == STATE_DRAINING) | |
| 844 return ERR_CONNECTION_CLOSED; | 843 return ERR_CONNECTION_CLOSED; |
| 844 } |
| 845 | 845 |
| 846 *stream = GetActivePushStream(url); | 846 *stream = GetActivePushStream(url); |
| 847 if (*stream) { | 847 if (*stream) { |
| 848 DCHECK_LT(streams_pushed_and_claimed_count_, streams_pushed_count_); | 848 DCHECK_LT(streams_pushed_and_claimed_count_, streams_pushed_count_); |
| 849 streams_pushed_and_claimed_count_++; | 849 streams_pushed_and_claimed_count_++; |
| 850 | 850 |
| 851 // If the stream is still open, update its priority to match | 851 // If the stream is still open, update its priority to match |
| 852 // the priority of the matching request. | 852 // the priority of the matching request. |
| 853 if (!(*stream)->IsClosed() && (*stream)->priority() != priority) { | 853 if (!(*stream)->IsClosed() && (*stream)->priority() != priority) { |
| 854 (*stream)->set_priority(priority); | 854 (*stream)->set_priority(priority); |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 } | 1978 } |
| 1979 | 1979 |
| 1980 SpdyStreamId SpdySession::GetStreamIdForPush(const GURL& url) { | 1980 SpdyStreamId SpdySession::GetStreamIdForPush(const GURL& url) { |
| 1981 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = | 1981 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = |
| 1982 unclaimed_pushed_streams_.find(url); | 1982 unclaimed_pushed_streams_.find(url); |
| 1983 if (unclaimed_it == unclaimed_pushed_streams_.end()) | 1983 if (unclaimed_it == unclaimed_pushed_streams_.end()) |
| 1984 return 0; | 1984 return 0; |
| 1985 return unclaimed_it->second.stream_id; | 1985 return unclaimed_it->second.stream_id; |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 base::WeakPtr<SpdyStream> SpdySession::GetActivePushStream(const GURL& url) { | 1988 SpdyStream* SpdySession::GetActivePushStream(const GURL& url) { |
| 1989 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = | 1989 UnclaimedPushedStreamContainer::const_iterator unclaimed_it = |
| 1990 unclaimed_pushed_streams_.find(url); | 1990 unclaimed_pushed_streams_.find(url); |
| 1991 if (unclaimed_it == unclaimed_pushed_streams_.end()) | 1991 if (unclaimed_it == unclaimed_pushed_streams_.end()) |
| 1992 return base::WeakPtr<SpdyStream>(); | 1992 return nullptr; |
| 1993 | 1993 |
| 1994 SpdyStreamId stream_id = unclaimed_it->second.stream_id; | 1994 SpdyStreamId stream_id = unclaimed_it->second.stream_id; |
| 1995 unclaimed_pushed_streams_.erase(unclaimed_it); | 1995 unclaimed_pushed_streams_.erase(unclaimed_it); |
| 1996 | 1996 |
| 1997 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); | 1997 ActiveStreamMap::iterator active_it = active_streams_.find(stream_id); |
| 1998 if (active_it == active_streams_.end()) { | 1998 if (active_it == active_streams_.end()) { |
| 1999 NOTREACHED(); | 1999 NOTREACHED(); |
| 2000 return base::WeakPtr<SpdyStream>(); | 2000 return nullptr; |
| 2001 } | 2001 } |
| 2002 | 2002 |
| 2003 net_log_.AddEvent(NetLogEventType::HTTP2_STREAM_ADOPTED_PUSH_STREAM, | 2003 net_log_.AddEvent(NetLogEventType::HTTP2_STREAM_ADOPTED_PUSH_STREAM, |
| 2004 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, | 2004 base::Bind(&NetLogSpdyAdoptedPushStreamCallback, |
| 2005 active_it->second->stream_id(), &url)); | 2005 active_it->second->stream_id(), &url)); |
| 2006 return active_it->second->GetWeakPtr(); | 2006 return active_it->second; |
| 2007 } | 2007 } |
| 2008 | 2008 |
| 2009 url::SchemeHostPort SpdySession::GetServer() { | 2009 url::SchemeHostPort SpdySession::GetServer() { |
| 2010 return url::SchemeHostPort(is_secure_ ? "https" : "http", | 2010 return url::SchemeHostPort(is_secure_ ? "https" : "http", |
| 2011 host_port_pair().host(), host_port_pair().port()); | 2011 host_port_pair().host(), host_port_pair().port()); |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 bool SpdySession::GetRemoteEndpoint(IPEndPoint* endpoint) { | 2014 bool SpdySession::GetRemoteEndpoint(IPEndPoint* endpoint) { |
| 2015 return GetPeerAddress(endpoint) == OK; | 2015 return GetPeerAddress(endpoint) == OK; |
| 2016 } | 2016 } |
| (...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 if (!queue->empty()) { | 3118 if (!queue->empty()) { |
| 3119 SpdyStreamId stream_id = queue->front(); | 3119 SpdyStreamId stream_id = queue->front(); |
| 3120 queue->pop_front(); | 3120 queue->pop_front(); |
| 3121 return stream_id; | 3121 return stream_id; |
| 3122 } | 3122 } |
| 3123 } | 3123 } |
| 3124 return 0; | 3124 return 0; |
| 3125 } | 3125 } |
| 3126 | 3126 |
| 3127 } // namespace net | 3127 } // namespace net |
| OLD | NEW |