| 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" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/trace_event/memory_allocator_dump.h" | 15 #include "base/trace_event/memory_allocator_dump.h" |
| 16 #include "base/trace_event/process_memory_dump.h" | 16 #include "base/trace_event/process_memory_dump.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
| 20 #include "net/base/trace_constants.h" | 20 #include "net/base/trace_constants.h" |
| 21 #include "net/http/http_network_session.h" | 21 #include "net/http/http_network_session.h" |
| 22 #include "net/http/http_server_properties.h" | 22 #include "net/http/http_server_properties.h" |
| 23 #include "net/log/net_log_event_type.h" | 23 #include "net/log/net_log_event_type.h" |
| 24 #include "net/log/net_log_source.h" | 24 #include "net/log/net_log_source.h" |
| 25 #include "net/log/net_log_with_source.h" | 25 #include "net/log/net_log_with_source.h" |
| 26 #include "net/spdy/hpack/hpack_constants.h" |
| 27 #include "net/spdy/hpack/hpack_huffman_table.h" |
| 28 #include "net/spdy/hpack/hpack_static_table.h" |
| 29 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
| 26 #include "net/spdy/spdy_session.h" | 30 #include "net/spdy/spdy_session.h" |
| 27 | 31 |
| 28 namespace net { | 32 namespace net { |
| 29 | 33 |
| 30 namespace { | 34 namespace { |
| 31 | 35 |
| 32 enum SpdySessionGetTypes { | 36 enum SpdySessionGetTypes { |
| 33 CREATED_NEW = 0, | 37 CREATED_NEW = 0, |
| 34 FOUND_EXISTING = 1, | 38 FOUND_EXISTING = 1, |
| 35 FOUND_EXISTING_FROM_IP_POOL = 2, | 39 FOUND_EXISTING_FROM_IP_POOL = 2, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 if (sessions_.empty()) | 378 if (sessions_.empty()) |
| 375 return; | 379 return; |
| 376 size_t total_size = 0; | 380 size_t total_size = 0; |
| 377 size_t buffer_size = 0; | 381 size_t buffer_size = 0; |
| 378 size_t cert_count = 0; | 382 size_t cert_count = 0; |
| 379 size_t serialized_cert_size = 0; | 383 size_t serialized_cert_size = 0; |
| 380 size_t num_active_sessions = 0; | 384 size_t num_active_sessions = 0; |
| 381 for (const auto& session : sessions_) { | 385 for (const auto& session : sessions_) { |
| 382 StreamSocket::SocketMemoryStats stats; | 386 StreamSocket::SocketMemoryStats stats; |
| 383 bool is_session_active = false; | 387 bool is_session_active = false; |
| 384 session->DumpMemoryStats(&stats, &is_session_active); | 388 total_size += session->DumpMemoryStats(&stats, &is_session_active); |
| 385 total_size += stats.total_size; | |
| 386 buffer_size += stats.buffer_size; | 389 buffer_size += stats.buffer_size; |
| 387 cert_count += stats.cert_count; | 390 cert_count += stats.cert_count; |
| 388 serialized_cert_size += stats.serialized_cert_size; | 391 serialized_cert_size += stats.serialized_cert_size; |
| 389 if (is_session_active) | 392 if (is_session_active) |
| 390 num_active_sessions++; | 393 num_active_sessions++; |
| 391 } | 394 } |
| 395 total_size += SpdyEstimateMemoryUsage(ObtainHpackHuffmanTable()) + |
| 396 SpdyEstimateMemoryUsage(ObtainHpackStaticTable()); |
| 392 base::trace_event::MemoryAllocatorDump* dump = | 397 base::trace_event::MemoryAllocatorDump* dump = |
| 393 pmd->CreateAllocatorDump(base::StringPrintf( | 398 pmd->CreateAllocatorDump(base::StringPrintf( |
| 394 "%s/spdy_session_pool", parent_dump_absolute_name.c_str())); | 399 "%s/spdy_session_pool", parent_dump_absolute_name.c_str())); |
| 395 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 400 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 396 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 401 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 397 total_size); | 402 total_size); |
| 398 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 403 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 399 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 404 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 400 sessions_.size()); | 405 sessions_.size()); |
| 401 dump->AddScalar("active_session_count", | 406 dump->AddScalar("active_session_count", |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 483 |
| 479 if (idle_only && (*it)->is_active()) | 484 if (idle_only && (*it)->is_active()) |
| 480 continue; | 485 continue; |
| 481 | 486 |
| 482 (*it)->CloseSessionOnError(error, description); | 487 (*it)->CloseSessionOnError(error, description); |
| 483 DCHECK(!IsSessionAvailable(*it)); | 488 DCHECK(!IsSessionAvailable(*it)); |
| 484 } | 489 } |
| 485 } | 490 } |
| 486 | 491 |
| 487 } // namespace net | 492 } // namespace net |
| OLD | NEW |