OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_pool.h" | 5 #include "net/spdy/spdy_session_pool.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/spdy/spdy_session.h" | 8 #include "net/spdy/spdy_session.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DCHECK(list); | 44 DCHECK(list); |
45 if (!spdy_session) | 45 if (!spdy_session) |
46 spdy_session = new SpdySession(host_port_pair, session, net_log.net_log()); | 46 spdy_session = new SpdySession(host_port_pair, session, net_log.net_log()); |
47 | 47 |
48 DCHECK(spdy_session); | 48 DCHECK(spdy_session); |
49 list->push_back(spdy_session); | 49 list->push_back(spdy_session); |
50 DCHECK_LE(list->size(), static_cast<unsigned int>(g_max_sessions_per_domain)); | 50 DCHECK_LE(list->size(), static_cast<unsigned int>(g_max_sessions_per_domain)); |
51 return spdy_session; | 51 return spdy_session; |
52 } | 52 } |
53 | 53 |
54 scoped_refptr<SpdySession> SpdySessionPool::GetSpdySessionFromSSLSocket( | 54 net::Error SpdySessionPool::GetSpdySessionFromSSLSocket( |
55 const HostPortPair& host_port_pair, | 55 const HostPortPair& host_port_pair, |
56 HttpNetworkSession* session, | 56 HttpNetworkSession* session, |
57 ClientSocketHandle* connection, | 57 ClientSocketHandle* connection, |
58 const BoundNetLog& net_log) { | 58 const BoundNetLog& net_log, |
| 59 scoped_refptr<SpdySession>& spdy_session) { |
| 60 // Create the SPDY session and add it to the pool. |
| 61 spdy_session = (new SpdySession(host_port_pair, session, net_log.net_log())); |
59 SpdySessionList* list = GetSessionList(host_port_pair); | 62 SpdySessionList* list = GetSessionList(host_port_pair); |
60 if (!list) | 63 if (!list) |
61 list = AddSessionList(host_port_pair); | 64 list = AddSessionList(host_port_pair); |
62 DCHECK(list->empty()); | 65 DCHECK(list->empty()); |
63 scoped_refptr<SpdySession> spdy_session( | |
64 new SpdySession(host_port_pair, session, net_log.net_log())); | |
65 spdy_session->InitializeWithSSLSocket(connection); | |
66 list->push_back(spdy_session); | 66 list->push_back(spdy_session); |
67 return spdy_session; | 67 |
| 68 // Now we can initialize the session with the SSL socket. |
| 69 return spdy_session->InitializeWithSSLSocket(connection); |
68 } | 70 } |
69 | 71 |
70 bool SpdySessionPool::HasSession(const HostPortPair& host_port_pair) const { | 72 bool SpdySessionPool::HasSession(const HostPortPair& host_port_pair) const { |
71 if (GetSessionList(host_port_pair)) | 73 if (GetSessionList(host_port_pair)) |
72 return true; | 74 return true; |
73 return false; | 75 return false; |
74 } | 76 } |
75 | 77 |
76 void SpdySessionPool::Remove(const scoped_refptr<SpdySession>& session) { | 78 void SpdySessionPool::Remove(const scoped_refptr<SpdySession>& session) { |
77 SpdySessionList* list = GetSessionList(session->host_port_pair()); | 79 SpdySessionList* list = GetSessionList(session->host_port_pair()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 scoped_refptr<SpdySession> session = list->front(); | 128 scoped_refptr<SpdySession> session = list->front(); |
127 list->pop_front(); | 129 list->pop_front(); |
128 if (close) | 130 if (close) |
129 session->CloseAllStreams(net::ERR_ABORTED); | 131 session->CloseAllStreams(net::ERR_ABORTED); |
130 } | 132 } |
131 delete list; | 133 delete list; |
132 } | 134 } |
133 } | 135 } |
134 | 136 |
135 } // namespace net | 137 } // namespace net |
OLD | NEW |