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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 void SpdySessionPool::CloseAllSessions() { | 402 void SpdySessionPool::CloseAllSessions() { |
403 while (!sessions_.empty()) { | 403 while (!sessions_.empty()) { |
404 SpdySessionList* list = sessions_.begin()->second; | 404 SpdySessionList* list = sessions_.begin()->second; |
405 CHECK(list); | 405 CHECK(list); |
406 const scoped_refptr<SpdySession>& session = list->front(); | 406 const scoped_refptr<SpdySession>& session = list->front(); |
407 CHECK(session); | 407 CHECK(session); |
408 // This call takes care of removing the session from the pool, as well as | 408 // This call takes care of removing the session from the pool, as well as |
409 // removing the session list if the list is empty. | 409 // removing the session list if the list is empty. |
410 session->CloseSessionOnError( | 410 session->CloseSessionOnError( |
411 net::ERR_ABORTED, true, "Closing all sessions."); | 411 net::ERR_ABORTED, SPDY_NO_ERROR, true, "Closing all sessions."); |
412 } | 412 } |
413 } | 413 } |
414 | 414 |
415 void SpdySessionPool::CloseCurrentSessions() { | 415 void SpdySessionPool::CloseCurrentSessions() { |
416 SpdySessionsMap old_map; | 416 SpdySessionsMap old_map; |
417 old_map.swap(sessions_); | 417 old_map.swap(sessions_); |
418 for (SpdySessionsMap::const_iterator it = old_map.begin(); | 418 for (SpdySessionsMap::const_iterator it = old_map.begin(); |
419 it != old_map.end(); ++it) { | 419 it != old_map.end(); ++it) { |
420 SpdySessionList* list = it->second; | 420 SpdySessionList* list = it->second; |
421 CHECK(list); | 421 CHECK(list); |
422 const scoped_refptr<SpdySession>& session = list->front(); | 422 const scoped_refptr<SpdySession>& session = list->front(); |
423 CHECK(session); | 423 CHECK(session); |
424 session->set_spdy_session_pool(NULL); | 424 session->set_spdy_session_pool(NULL); |
425 } | 425 } |
426 | 426 |
427 while (!old_map.empty()) { | 427 while (!old_map.empty()) { |
428 SpdySessionList* list = old_map.begin()->second; | 428 SpdySessionList* list = old_map.begin()->second; |
429 CHECK(list); | 429 CHECK(list); |
430 const scoped_refptr<SpdySession>& session = list->front(); | 430 const scoped_refptr<SpdySession>& session = list->front(); |
431 CHECK(session); | 431 CHECK(session); |
432 session->CloseSessionOnError( | 432 session->CloseSessionOnError( |
433 net::ERR_ABORTED, false, "Closing current sessions."); | 433 net::ERR_ABORTED, SPDY_NO_ERROR, false, "Closing current sessions."); |
434 list->pop_front(); | 434 list->pop_front(); |
435 if (list->empty()) { | 435 if (list->empty()) { |
436 delete list; | 436 delete list; |
437 RemoveAliases(old_map.begin()->first); | 437 RemoveAliases(old_map.begin()->first); |
438 old_map.erase(old_map.begin()->first); | 438 old_map.erase(old_map.begin()->first); |
439 } | 439 } |
440 } | 440 } |
441 DCHECK(sessions_.empty()); | 441 DCHECK(sessions_.empty()); |
442 DCHECK(aliases_.empty()); | 442 DCHECK(aliases_.empty()); |
443 } | 443 } |
444 | 444 |
445 void SpdySessionPool::CloseIdleSessions() { | 445 void SpdySessionPool::CloseIdleSessions() { |
446 SpdySessionsMap::const_iterator map_it = sessions_.begin(); | 446 SpdySessionsMap::const_iterator map_it = sessions_.begin(); |
447 while (map_it != sessions_.end()) { | 447 while (map_it != sessions_.end()) { |
448 SpdySessionList* list = map_it->second; | 448 SpdySessionList* list = map_it->second; |
449 ++map_it; | 449 ++map_it; |
450 CHECK(list); | 450 CHECK(list); |
451 | 451 |
452 // Assumes there is only 1 element in the list | 452 // Assumes there is only 1 element in the list |
453 SpdySessionList::iterator session_it = list->begin(); | 453 SpdySessionList::iterator session_it = list->begin(); |
454 const scoped_refptr<SpdySession>& session = *session_it; | 454 const scoped_refptr<SpdySession>& session = *session_it; |
455 CHECK(session); | 455 CHECK(session); |
456 if (!session->is_active()) { | 456 if (!session->is_active()) { |
457 session->CloseSessionOnError( | 457 session->CloseSessionOnError( |
458 net::ERR_ABORTED, true, "Closing idle sessions."); | 458 net::ERR_ABORTED, SPDY_NO_ERROR, true, "Closing idle sessions."); |
459 } | 459 } |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 } // namespace net | 463 } // namespace net |
OLD | NEW |