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_pool.h" | 5 #include "net/spdy/spdy_session_pool.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
9 #include "base/profiler/scoped_tracker.h" | 11 #include "base/profiler/scoped_tracker.h" |
10 #include "base/values.h" | 12 #include "base/values.h" |
11 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
12 #include "net/http/http_network_session.h" | 14 #include "net/http/http_network_session.h" |
13 #include "net/http/http_server_properties.h" | 15 #include "net/http/http_server_properties.h" |
14 #include "net/spdy/spdy_session.h" | 16 #include "net/spdy/spdy_session.h" |
15 | 17 |
16 namespace net { | 18 namespace net { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 "Net.SpdySessionGet", IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); | 96 "Net.SpdySessionGet", IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); |
95 | 97 |
96 scoped_ptr<SpdySession> new_session(new SpdySession( | 98 scoped_ptr<SpdySession> new_session(new SpdySession( |
97 key, http_server_properties_, transport_security_state_, | 99 key, http_server_properties_, transport_security_state_, |
98 verify_domain_authentication_, enable_sending_initial_data_, | 100 verify_domain_authentication_, enable_sending_initial_data_, |
99 enable_compression_, enable_ping_based_connection_checking_, | 101 enable_compression_, enable_ping_based_connection_checking_, |
100 default_protocol_, session_max_recv_window_size_, | 102 default_protocol_, session_max_recv_window_size_, |
101 stream_max_recv_window_size_, initial_max_concurrent_streams_, time_func_, | 103 stream_max_recv_window_size_, initial_max_concurrent_streams_, time_func_, |
102 trusted_spdy_proxy_, net_log.net_log())); | 104 trusted_spdy_proxy_, net_log.net_log())); |
103 | 105 |
104 new_session->InitializeWithSocket( | 106 new_session->InitializeWithSocket(std::move(connection), this, is_secure, |
105 connection.Pass(), this, is_secure, certificate_error_code); | 107 certificate_error_code); |
106 | 108 |
107 base::WeakPtr<SpdySession> available_session = new_session->GetWeakPtr(); | 109 base::WeakPtr<SpdySession> available_session = new_session->GetWeakPtr(); |
108 sessions_.insert(new_session.release()); | 110 sessions_.insert(new_session.release()); |
109 MapKeyToAvailableSession(key, available_session); | 111 MapKeyToAvailableSession(key, available_session); |
110 | 112 |
111 net_log.AddEvent( | 113 net_log.AddEvent( |
112 NetLog::TYPE_HTTP2_SESSION_POOL_IMPORTED_SESSION_FROM_SOCKET, | 114 NetLog::TYPE_HTTP2_SESSION_POOL_IMPORTED_SESSION_FROM_SOCKET, |
113 available_session->net_log().source().ToEventParametersCallback()); | 115 available_session->net_log().source().ToEventParametersCallback()); |
114 | 116 |
115 // Look up the IP address for this session so that we can match | 117 // Look up the IP address for this session so that we can match |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 254 |
253 for (AvailableSessionMap::const_iterator it = available_sessions_.begin(); | 255 for (AvailableSessionMap::const_iterator it = available_sessions_.begin(); |
254 it != available_sessions_.end(); ++it) { | 256 it != available_sessions_.end(); ++it) { |
255 // Only add the session if the key in the map matches the main | 257 // Only add the session if the key in the map matches the main |
256 // host_port_proxy_pair (not an alias). | 258 // host_port_proxy_pair (not an alias). |
257 const SpdySessionKey& key = it->first; | 259 const SpdySessionKey& key = it->first; |
258 const SpdySessionKey& session_key = it->second->spdy_session_key(); | 260 const SpdySessionKey& session_key = it->second->spdy_session_key(); |
259 if (key.Equals(session_key)) | 261 if (key.Equals(session_key)) |
260 list->Append(it->second->GetInfoAsValue()); | 262 list->Append(it->second->GetInfoAsValue()); |
261 } | 263 } |
262 return list.Pass(); | 264 return std::move(list); |
263 } | 265 } |
264 | 266 |
265 void SpdySessionPool::OnIPAddressChanged() { | 267 void SpdySessionPool::OnIPAddressChanged() { |
266 WeakSessionList current_sessions = GetCurrentSessions(); | 268 WeakSessionList current_sessions = GetCurrentSessions(); |
267 for (WeakSessionList::const_iterator it = current_sessions.begin(); | 269 for (WeakSessionList::const_iterator it = current_sessions.begin(); |
268 it != current_sessions.end(); ++it) { | 270 it != current_sessions.end(); ++it) { |
269 if (!*it) | 271 if (!*it) |
270 continue; | 272 continue; |
271 | 273 |
272 // For OSs that terminate TCP connections upon relevant network changes, | 274 // For OSs that terminate TCP connections upon relevant network changes, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 371 |
370 if (idle_only && (*it)->is_active()) | 372 if (idle_only && (*it)->is_active()) |
371 continue; | 373 continue; |
372 | 374 |
373 (*it)->CloseSessionOnError(error, description); | 375 (*it)->CloseSessionOnError(error, description); |
374 DCHECK(!IsSessionAvailable(*it)); | 376 DCHECK(!IsSessionAvailable(*it)); |
375 } | 377 } |
376 } | 378 } |
377 | 379 |
378 } // namespace net | 380 } // namespace net |
OLD | NEW |