| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 const HostPortProxyPair& key = it->first; | 268 const HostPortProxyPair& key = it->first; |
| 269 const HostPortProxyPair& pair = session->get()->host_port_proxy_pair(); | 269 const HostPortProxyPair& pair = session->get()->host_port_proxy_pair(); |
| 270 if (key.first.Equals(pair.first) && key.second == pair.second) | 270 if (key.first.Equals(pair.first) && key.second == pair.second) |
| 271 list->Append(session->get()->GetInfoAsValue()); | 271 list->Append(session->get()->GetInfoAsValue()); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 return list; | 274 return list; |
| 275 } | 275 } |
| 276 | 276 |
| 277 void SpdySessionPool::OnIPAddressChanged() { | 277 void SpdySessionPool::OnIPAddressChanged() { |
| 278 CloseCurrentSessions(); | 278 CloseCurrentSessions(ERR_NETWORK_CHANGED); |
| 279 http_server_properties_->ClearSpdySettings(); | 279 http_server_properties_->ClearSpdySettings(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void SpdySessionPool::OnSSLConfigChanged() { | 282 void SpdySessionPool::OnSSLConfigChanged() { |
| 283 CloseCurrentSessions(); | 283 CloseCurrentSessions(ERR_ABORTED); |
| 284 } | 284 } |
| 285 | 285 |
| 286 scoped_refptr<SpdySession> SpdySessionPool::GetExistingSession( | 286 scoped_refptr<SpdySession> SpdySessionPool::GetExistingSession( |
| 287 SpdySessionList* list, | 287 SpdySessionList* list, |
| 288 const BoundNetLog& net_log) const { | 288 const BoundNetLog& net_log) const { |
| 289 DCHECK(list); | 289 DCHECK(list); |
| 290 DCHECK_LT(0u, list->size()); | 290 DCHECK_LT(0u, list->size()); |
| 291 scoped_refptr<SpdySession> spdy_session = list->front(); | 291 scoped_refptr<SpdySession> spdy_session = list->front(); |
| 292 if (list->size() > 1) { | 292 if (list->size() > 1) { |
| 293 list->pop_front(); // Rotate the list. | 293 list->pop_front(); // Rotate the list. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 continue; | 340 continue; |
| 341 } | 341 } |
| 342 if (record_histograms) | 342 if (record_histograms) |
| 343 UMA_HISTOGRAM_ENUMERATION("Net.SpdyIPPoolDomainMatch", 1, 2); | 343 UMA_HISTOGRAM_ENUMERATION("Net.SpdyIPPoolDomainMatch", 1, 2); |
| 344 return spdy_session; | 344 return spdy_session; |
| 345 } | 345 } |
| 346 return NULL; | 346 return NULL; |
| 347 } | 347 } |
| 348 | 348 |
| 349 void SpdySessionPool::OnCertAdded(const X509Certificate* cert) { | 349 void SpdySessionPool::OnCertAdded(const X509Certificate* cert) { |
| 350 CloseCurrentSessions(); | 350 CloseCurrentSessions(ERR_ABORTED); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void SpdySessionPool::OnCertTrustChanged(const X509Certificate* cert) { | 353 void SpdySessionPool::OnCertTrustChanged(const X509Certificate* cert) { |
| 354 // Per wtc, we actually only need to CloseCurrentSessions when trust is | 354 // Per wtc, we actually only need to CloseCurrentSessions when trust is |
| 355 // reduced. CloseCurrentSessions now because OnCertTrustChanged does not | 355 // reduced. CloseCurrentSessions now because OnCertTrustChanged does not |
| 356 // tell us this. | 356 // tell us this. |
| 357 // See comments in ClientSocketPoolManager::OnCertTrustChanged. | 357 // See comments in ClientSocketPoolManager::OnCertTrustChanged. |
| 358 CloseCurrentSessions(); | 358 CloseCurrentSessions(ERR_ABORTED); |
| 359 } | 359 } |
| 360 | 360 |
| 361 const HostPortProxyPair& SpdySessionPool::NormalizeListPair( | 361 const HostPortProxyPair& SpdySessionPool::NormalizeListPair( |
| 362 const HostPortProxyPair& host_port_proxy_pair) const { | 362 const HostPortProxyPair& host_port_proxy_pair) const { |
| 363 if (!force_single_domain_) | 363 if (!force_single_domain_) |
| 364 return host_port_proxy_pair; | 364 return host_port_proxy_pair; |
| 365 | 365 |
| 366 static HostPortProxyPair* single_domain_pair = NULL; | 366 static HostPortProxyPair* single_domain_pair = NULL; |
| 367 if (!single_domain_pair) { | 367 if (!single_domain_pair) { |
| 368 HostPortPair single_domain = HostPortPair("singledomain.com", 80); | 368 HostPortPair single_domain = HostPortPair("singledomain.com", 80); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 CHECK(list); | 440 CHECK(list); |
| 441 const scoped_refptr<SpdySession>& session = list->front(); | 441 const scoped_refptr<SpdySession>& session = list->front(); |
| 442 CHECK(session); | 442 CHECK(session); |
| 443 // This call takes care of removing the session from the pool, as well as | 443 // This call takes care of removing the session from the pool, as well as |
| 444 // removing the session list if the list is empty. | 444 // removing the session list if the list is empty. |
| 445 session->CloseSessionOnError( | 445 session->CloseSessionOnError( |
| 446 net::ERR_ABORTED, true, "Closing all sessions."); | 446 net::ERR_ABORTED, true, "Closing all sessions."); |
| 447 } | 447 } |
| 448 } | 448 } |
| 449 | 449 |
| 450 void SpdySessionPool::CloseCurrentSessions() { | 450 void SpdySessionPool::CloseCurrentSessions(net::Error error) { |
| 451 SpdySessionsMap old_map; | 451 SpdySessionsMap old_map; |
| 452 old_map.swap(sessions_); | 452 old_map.swap(sessions_); |
| 453 for (SpdySessionsMap::const_iterator it = old_map.begin(); | 453 for (SpdySessionsMap::const_iterator it = old_map.begin(); |
| 454 it != old_map.end(); ++it) { | 454 it != old_map.end(); ++it) { |
| 455 SpdySessionList* list = it->second; | 455 SpdySessionList* list = it->second; |
| 456 CHECK(list); | 456 CHECK(list); |
| 457 const scoped_refptr<SpdySession>& session = list->front(); | 457 const scoped_refptr<SpdySession>& session = list->front(); |
| 458 CHECK(session); | 458 CHECK(session); |
| 459 session->set_spdy_session_pool(NULL); | 459 session->set_spdy_session_pool(NULL); |
| 460 } | 460 } |
| 461 | 461 |
| 462 while (!old_map.empty()) { | 462 while (!old_map.empty()) { |
| 463 SpdySessionList* list = old_map.begin()->second; | 463 SpdySessionList* list = old_map.begin()->second; |
| 464 CHECK(list); | 464 CHECK(list); |
| 465 const scoped_refptr<SpdySession>& session = list->front(); | 465 const scoped_refptr<SpdySession>& session = list->front(); |
| 466 CHECK(session); | 466 CHECK(session); |
| 467 session->CloseSessionOnError( | 467 session->CloseSessionOnError(error, false, "Closing current sessions."); |
| 468 net::ERR_ABORTED, false, "Closing current sessions."); | |
| 469 list->pop_front(); | 468 list->pop_front(); |
| 470 if (list->empty()) { | 469 if (list->empty()) { |
| 471 delete list; | 470 delete list; |
| 472 RemoveAliases(old_map.begin()->first); | 471 RemoveAliases(old_map.begin()->first); |
| 473 old_map.erase(old_map.begin()->first); | 472 old_map.erase(old_map.begin()->first); |
| 474 } | 473 } |
| 475 } | 474 } |
| 476 DCHECK(sessions_.empty()); | 475 DCHECK(sessions_.empty()); |
| 477 DCHECK(aliases_.empty()); | 476 DCHECK(aliases_.empty()); |
| 478 } | 477 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 489 const scoped_refptr<SpdySession>& session = *session_it; | 488 const scoped_refptr<SpdySession>& session = *session_it; |
| 490 CHECK(session); | 489 CHECK(session); |
| 491 if (!session->is_active()) { | 490 if (!session->is_active()) { |
| 492 session->CloseSessionOnError( | 491 session->CloseSessionOnError( |
| 493 net::ERR_ABORTED, true, "Closing idle sessions."); | 492 net::ERR_ABORTED, true, "Closing idle sessions."); |
| 494 } | 493 } |
| 495 } | 494 } |
| 496 } | 495 } |
| 497 | 496 |
| 498 } // namespace net | 497 } // namespace net |
| OLD | NEW |