Chromium Code Reviews| 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 CloseCurrentSessions(ERR_NETWORK_CHANGED); | 364 CloseCurrentSessions(ERR_NETWORK_CHANGED); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void SpdySessionPool::OnCertDBChanged(const X509Certificate* cert) { | 367 void SpdySessionPool::OnCertDBChanged(const X509Certificate* cert) { |
| 368 CloseCurrentSessions(ERR_CERT_DATABASE_CHANGED); | 368 CloseCurrentSessions(ERR_CERT_DATABASE_CHANGED); |
| 369 } | 369 } |
| 370 | 370 |
| 371 void SpdySessionPool::DumpMemoryStats( | 371 void SpdySessionPool::DumpMemoryStats( |
| 372 base::trace_event::ProcessMemoryDump* pmd, | 372 base::trace_event::ProcessMemoryDump* pmd, |
| 373 const std::string& parent_dump_absolute_name) const { | 373 const std::string& parent_dump_absolute_name) const { |
| 374 std::string dump_name = base::StringPrintf("%s/spdy_session_pool", | |
| 375 parent_dump_absolute_name.c_str()); | |
| 376 base::trace_event::MemoryAllocatorDump* dump = | |
| 377 pmd->CreateAllocatorDump(dump_name); | |
| 378 size_t total_size = 0; | 374 size_t total_size = 0; |
| 379 size_t buffer_size = 0; | 375 size_t buffer_size = 0; |
| 380 size_t cert_count = 0; | 376 size_t cert_count = 0; |
| 381 size_t serialized_cert_size = 0; | 377 size_t serialized_cert_size = 0; |
| 382 size_t num_active_sessions = 0; | 378 size_t num_active_sessions = 0; |
| 383 for (const auto& session : sessions_) { | 379 for (const auto& session : sessions_) { |
| 384 StreamSocket::SocketMemoryStats stats; | 380 StreamSocket::SocketMemoryStats stats; |
| 385 bool is_session_active = false; | 381 bool is_session_active = false; |
| 386 session->DumpMemoryStats(&stats, &is_session_active); | 382 session->DumpMemoryStats(&stats, &is_session_active); |
| 387 total_size += stats.total_size; | 383 total_size += stats.total_size; |
| 388 buffer_size += stats.buffer_size; | 384 buffer_size += stats.buffer_size; |
| 389 cert_count += stats.cert_count; | 385 cert_count += stats.cert_count; |
| 390 serialized_cert_size += stats.serialized_cert_size; | 386 serialized_cert_size += stats.serialized_cert_size; |
| 391 if (is_session_active) | 387 if (is_session_active) |
| 392 num_active_sessions++; | 388 num_active_sessions++; |
| 393 } | 389 } |
| 390 if (sessions_.empty()) | |
|
ssid
2017/01/20 21:35:58
Could do this at the start of the function. But w
xunjieli
2017/01/20 21:45:26
Done. Good point!
| |
| 391 return; | |
| 392 base::trace_event::MemoryAllocatorDump* dump = | |
| 393 pmd->CreateAllocatorDump(base::StringPrintf( | |
| 394 "%s/spdy_session_pool", parent_dump_absolute_name.c_str())); | |
| 394 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 395 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 395 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 396 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 396 total_size); | 397 total_size); |
| 397 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 398 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 398 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 399 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 399 sessions_.size()); | 400 sessions_.size()); |
| 400 dump->AddScalar("active_session_count", | 401 dump->AddScalar("active_session_count", |
| 401 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 402 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 402 num_active_sessions); | 403 num_active_sessions); |
| 403 dump->AddScalar("buffer_size", | 404 dump->AddScalar("buffer_size", |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 | 478 |
| 478 if (idle_only && (*it)->is_active()) | 479 if (idle_only && (*it)->is_active()) |
| 479 continue; | 480 continue; |
| 480 | 481 |
| 481 (*it)->CloseSessionOnError(error, description); | 482 (*it)->CloseSessionOnError(error, description); |
| 482 DCHECK(!IsSessionAvailable(*it)); | 483 DCHECK(!IsSessionAvailable(*it)); |
| 483 } | 484 } |
| 484 } | 485 } |
| 485 | 486 |
| 486 } // namespace net | 487 } // namespace net |
| OLD | NEW |