| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 365 |
| 366 void SpdySessionPool::OnCertDBChanged(const X509Certificate* cert) { | 366 void SpdySessionPool::OnCertDBChanged(const X509Certificate* cert) { |
| 367 CloseCurrentSessions(ERR_CERT_DATABASE_CHANGED); | 367 CloseCurrentSessions(ERR_CERT_DATABASE_CHANGED); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void SpdySessionPool::DumpMemoryStats( | 370 void SpdySessionPool::DumpMemoryStats( |
| 371 base::trace_event::ProcessMemoryDump* pmd, | 371 base::trace_event::ProcessMemoryDump* pmd, |
| 372 const std::string& parent_dump_absolute_name) const { | 372 const std::string& parent_dump_absolute_name) const { |
| 373 std::string dump_name = base::StringPrintf("%s/spdy_session_pool", | 373 std::string dump_name = base::StringPrintf("%s/spdy_session_pool", |
| 374 parent_dump_absolute_name.c_str()); | 374 parent_dump_absolute_name.c_str()); |
| 375 pmd->CreateAllocatorDump(dump_name); | 375 base::trace_event::MemoryAllocatorDump* dump = |
| 376 pmd->CreateAllocatorDump(dump_name); |
| 377 size_t total_size = 0; |
| 378 size_t buffer_size = 0; |
| 379 size_t cert_count = 0; |
| 380 size_t serialized_cert_size = 0; |
| 381 size_t num_active_sessions = 0; |
| 376 for (const auto& session : sessions_) { | 382 for (const auto& session : sessions_) { |
| 377 session->DumpMemoryStats(pmd, dump_name); | 383 StreamSocket::SocketMemoryStats stats; |
| 384 bool is_session_active = false; |
| 385 session->DumpMemoryStats(&stats, &is_session_active); |
| 386 total_size += stats.total_size; |
| 387 buffer_size += stats.buffer_size; |
| 388 cert_count += stats.cert_count; |
| 389 serialized_cert_size += stats.serialized_cert_size; |
| 390 if (is_session_active) |
| 391 num_active_sessions++; |
| 378 } | 392 } |
| 393 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 394 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 395 total_size); |
| 396 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 397 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 398 sessions_.size()); |
| 399 dump->AddScalar("active_session_count", |
| 400 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 401 num_active_sessions); |
| 402 dump->AddScalar("buffer_size", |
| 403 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 404 buffer_size); |
| 405 dump->AddScalar("cert_count", |
| 406 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 407 cert_count); |
| 408 dump->AddScalar("serialized_cert_size", |
| 409 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 410 serialized_cert_size); |
| 379 } | 411 } |
| 380 | 412 |
| 381 bool SpdySessionPool::IsSessionAvailable( | 413 bool SpdySessionPool::IsSessionAvailable( |
| 382 const base::WeakPtr<SpdySession>& session) const { | 414 const base::WeakPtr<SpdySession>& session) const { |
| 383 for (AvailableSessionMap::const_iterator it = available_sessions_.begin(); | 415 for (AvailableSessionMap::const_iterator it = available_sessions_.begin(); |
| 384 it != available_sessions_.end(); ++it) { | 416 it != available_sessions_.end(); ++it) { |
| 385 if (it->second.get() == session.get()) | 417 if (it->second.get() == session.get()) |
| 386 return true; | 418 return true; |
| 387 } | 419 } |
| 388 return false; | 420 return false; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 476 |
| 445 if (idle_only && (*it)->is_active()) | 477 if (idle_only && (*it)->is_active()) |
| 446 continue; | 478 continue; |
| 447 | 479 |
| 448 (*it)->CloseSessionOnError(error, description); | 480 (*it)->CloseSessionOnError(error, description); |
| 449 DCHECK(!IsSessionAvailable(*it)); | 481 DCHECK(!IsSessionAvailable(*it)); |
| 450 } | 482 } |
| 451 } | 483 } |
| 452 | 484 |
| 453 } // namespace net | 485 } // namespace net |
| OLD | NEW |