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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 | 374 |
375 void SpdySessionPool::DumpMemoryStats( | 375 void SpdySessionPool::DumpMemoryStats( |
376 base::trace_event::ProcessMemoryDump* pmd, | 376 base::trace_event::ProcessMemoryDump* pmd, |
377 const std::string& parent_dump_absolute_name) const { | 377 const std::string& parent_dump_absolute_name) const { |
378 if (sessions_.empty()) | 378 if (sessions_.empty()) |
379 return; | 379 return; |
380 size_t total_size = 0; | 380 size_t total_size = 0; |
381 size_t buffer_size = 0; | 381 size_t buffer_size = 0; |
382 size_t cert_count = 0; | 382 size_t cert_count = 0; |
383 size_t serialized_cert_size = 0; | 383 size_t cert_size = 0; |
384 size_t num_active_sessions = 0; | 384 size_t num_active_sessions = 0; |
385 for (auto* session : sessions_) { | 385 for (auto* session : sessions_) { |
386 StreamSocket::SocketMemoryStats stats; | 386 StreamSocket::SocketMemoryStats stats; |
387 bool is_session_active = false; | 387 bool is_session_active = false; |
388 total_size += session->DumpMemoryStats(&stats, &is_session_active); | 388 total_size += session->DumpMemoryStats(&stats, &is_session_active); |
389 buffer_size += stats.buffer_size; | 389 buffer_size += stats.buffer_size; |
390 cert_count += stats.cert_count; | 390 cert_count += stats.cert_count; |
391 serialized_cert_size += stats.serialized_cert_size; | 391 cert_size += stats.cert_size; |
392 if (is_session_active) | 392 if (is_session_active) |
393 num_active_sessions++; | 393 num_active_sessions++; |
394 } | 394 } |
395 total_size += SpdyEstimateMemoryUsage(ObtainHpackHuffmanTable()) + | 395 total_size += SpdyEstimateMemoryUsage(ObtainHpackHuffmanTable()) + |
396 SpdyEstimateMemoryUsage(ObtainHpackStaticTable()); | 396 SpdyEstimateMemoryUsage(ObtainHpackStaticTable()); |
397 base::trace_event::MemoryAllocatorDump* dump = | 397 base::trace_event::MemoryAllocatorDump* dump = |
398 pmd->CreateAllocatorDump(base::StringPrintf( | 398 pmd->CreateAllocatorDump(base::StringPrintf( |
399 "%s/spdy_session_pool", parent_dump_absolute_name.c_str())); | 399 "%s/spdy_session_pool", parent_dump_absolute_name.c_str())); |
400 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 400 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
401 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 401 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
402 total_size); | 402 total_size); |
403 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 403 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
404 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 404 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
405 sessions_.size()); | 405 sessions_.size()); |
406 dump->AddScalar("active_session_count", | 406 dump->AddScalar("active_session_count", |
407 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 407 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
408 num_active_sessions); | 408 num_active_sessions); |
409 dump->AddScalar("buffer_size", | 409 dump->AddScalar("buffer_size", |
410 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 410 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
411 buffer_size); | 411 buffer_size); |
412 dump->AddScalar("cert_count", | 412 dump->AddScalar("cert_count", |
413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
414 cert_count); | 414 cert_count); |
415 dump->AddScalar("serialized_cert_size", | 415 dump->AddScalar("cert_size", |
416 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 416 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
417 serialized_cert_size); | 417 cert_size); |
418 } | 418 } |
419 | 419 |
420 bool SpdySessionPool::IsSessionAvailable( | 420 bool SpdySessionPool::IsSessionAvailable( |
421 const base::WeakPtr<SpdySession>& session) const { | 421 const base::WeakPtr<SpdySession>& session) const { |
422 for (AvailableSessionMap::const_iterator it = available_sessions_.begin(); | 422 for (AvailableSessionMap::const_iterator it = available_sessions_.begin(); |
423 it != available_sessions_.end(); ++it) { | 423 it != available_sessions_.end(); ++it) { |
424 if (it->second.get() == session.get()) | 424 if (it->second.get() == session.get()) |
425 return true; | 425 return true; |
426 } | 426 } |
427 return false; | 427 return false; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 if (idle_only && (*it)->is_active()) | 484 if (idle_only && (*it)->is_active()) |
485 continue; | 485 continue; |
486 | 486 |
487 (*it)->CloseSessionOnError(error, description); | 487 (*it)->CloseSessionOnError(error, description); |
488 DCHECK(!IsSessionAvailable(*it)); | 488 DCHECK(!IsSessionAvailable(*it)); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 } // namespace net | 492 } // namespace net |
OLD | NEW |