| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 job_controller_set_.size() <= last_logged_job_controller_count_) { | 365 job_controller_set_.size() <= last_logged_job_controller_count_) { |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 last_logged_job_controller_count_ = job_controller_set_.size(); | 368 last_logged_job_controller_count_ = job_controller_set_.size(); |
| 369 | 369 |
| 370 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobController", | 370 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobController", |
| 371 job_controller_set_.size()); | 371 job_controller_set_.size()); |
| 372 | 372 |
| 373 int alt_job_count = 0; | 373 int alt_job_count = 0; |
| 374 int main_job_count = 0; | 374 int main_job_count = 0; |
| 375 int pending_request_count = 0; | 375 size_t num_controllers_with_request = 0; |
| 376 int preconnect_controller_count = 0; | 376 size_t num_controllers_for_preconnect = 0; |
| 377 for (const auto& job_controller : job_controller_set_) { | 377 for (const auto& job_controller : job_controller_set_) { |
| 378 DCHECK(job_controller->HasPendingAltJob() || | 378 DCHECK(job_controller->HasPendingAltJob() || |
| 379 job_controller->HasPendingMainJob()); | 379 job_controller->HasPendingMainJob()); |
| 380 // Additionally logs the states of the jobs if there are at least 500 | 380 // Additionally logs the states of the jobs if there are at least 500 |
| 381 // controllers, which suggests that there might be a leak. | 381 // controllers, which suggests that there might be a leak. |
| 382 if (job_controller_set_.size() >= 500) | 382 if (job_controller_set_.size() >= 500) |
| 383 job_controller->LogHistograms(); | 383 job_controller->LogHistograms(); |
| 384 // For a preconnect controller, it should have exactly the main job. | 384 // For a preconnect controller, it should have exactly the main job. |
| 385 if (job_controller->is_preconnect()) { | 385 if (job_controller->is_preconnect()) { |
| 386 preconnect_controller_count++; | 386 num_controllers_for_preconnect++; |
| 387 continue; | 387 continue; |
| 388 } | 388 } |
| 389 // For non-preconnects. | 389 // For non-preconnects. |
| 390 if (job_controller->HasPendingRequest()) | 390 if (job_controller->HasPendingRequest()) |
| 391 pending_request_count++; | 391 num_controllers_with_request++; |
| 392 if (job_controller->HasPendingAltJob()) | 392 if (job_controller->HasPendingAltJob()) |
| 393 alt_job_count++; | 393 alt_job_count++; |
| 394 if (job_controller->HasPendingMainJob()) | 394 if (job_controller->HasPendingMainJob()) |
| 395 main_job_count++; | 395 main_job_count++; |
| 396 } | 396 } |
| 397 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect", | 397 UMA_HISTOGRAM_COUNTS_1M( |
| 398 preconnect_controller_count); | 398 "Net.JobControllerSet.CountOfJobController.Preconnect", |
| 399 num_controllers_for_preconnect); |
| 400 UMA_HISTOGRAM_COUNTS_1M( |
| 401 "Net.JobControllerSet.CountOfJobController.NonPreconnect.PendingRequest", |
| 402 num_controllers_with_request); |
| 403 |
| 404 UMA_HISTOGRAM_COUNTS_1M( |
| 405 "Net.JobControllerSet.CountOfJobController.NonPreconnect.RequestGone", |
| 406 job_controller_set_.size() - num_controllers_for_preconnect - |
| 407 num_controllers_with_request); |
| 408 |
| 399 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", | 409 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", |
| 400 alt_job_count); | 410 alt_job_count); |
| 401 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", | 411 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", |
| 402 main_job_count); | 412 main_job_count); |
| 403 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPendingRequest", | |
| 404 pending_request_count); | |
| 405 } | 413 } |
| 406 | 414 |
| 407 void HttpStreamFactoryImpl::DumpMemoryStats( | 415 void HttpStreamFactoryImpl::DumpMemoryStats( |
| 408 base::trace_event::ProcessMemoryDump* pmd, | 416 base::trace_event::ProcessMemoryDump* pmd, |
| 409 const std::string& parent_absolute_name) const { | 417 const std::string& parent_absolute_name) const { |
| 410 if (job_controller_set_.empty()) | 418 if (job_controller_set_.empty()) |
| 411 return; | 419 return; |
| 412 std::string name = | 420 std::string name = |
| 413 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); | 421 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); |
| 414 base::trace_event::MemoryAllocatorDump* factory_dump = | 422 base::trace_event::MemoryAllocatorDump* factory_dump = |
| 415 pmd->CreateAllocatorDump(name); | 423 pmd->CreateAllocatorDump(name); |
| 416 size_t alt_job_count = 0; | 424 size_t alt_job_count = 0; |
| 417 size_t main_job_count = 0; | 425 size_t main_job_count = 0; |
| 418 size_t preconnect_controller_count = 0; | 426 size_t num_controllers_for_preconnect = 0; |
| 419 for (const auto& it : job_controller_set_) { | 427 for (const auto& it : job_controller_set_) { |
| 420 // For a preconnect controller, it should have exactly the main job. | 428 // For a preconnect controller, it should have exactly the main job. |
| 421 if (it->is_preconnect()) { | 429 if (it->is_preconnect()) { |
| 422 preconnect_controller_count++; | 430 num_controllers_for_preconnect++; |
| 423 continue; | 431 continue; |
| 424 } | 432 } |
| 425 // For non-preconnects. | 433 // For non-preconnects. |
| 426 if (it->HasPendingAltJob()) | 434 if (it->HasPendingAltJob()) |
| 427 alt_job_count++; | 435 alt_job_count++; |
| 428 if (it->HasPendingMainJob()) | 436 if (it->HasPendingMainJob()) |
| 429 main_job_count++; | 437 main_job_count++; |
| 430 } | 438 } |
| 431 factory_dump->AddScalar( | 439 factory_dump->AddScalar( |
| 432 base::trace_event::MemoryAllocatorDump::kNameSize, | 440 base::trace_event::MemoryAllocatorDump::kNameSize, |
| 433 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 441 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 434 base::trace_event::EstimateMemoryUsage(job_controller_set_)); | 442 base::trace_event::EstimateMemoryUsage(job_controller_set_)); |
| 435 factory_dump->AddScalar( | 443 factory_dump->AddScalar( |
| 436 base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 444 base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 437 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 445 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 438 job_controller_set_.size()); | 446 job_controller_set_.size()); |
| 439 // The number of non-preconnect controllers with a pending alt job. | 447 // The number of non-preconnect controllers with a pending alt job. |
| 440 factory_dump->AddScalar("alt_job_count", | 448 factory_dump->AddScalar("alt_job_count", |
| 441 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 449 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 442 alt_job_count); | 450 alt_job_count); |
| 443 // The number of non-preconnect controllers with a pending main job. | 451 // The number of non-preconnect controllers with a pending main job. |
| 444 factory_dump->AddScalar("main_job_count", | 452 factory_dump->AddScalar("main_job_count", |
| 445 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 453 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 446 main_job_count); | 454 main_job_count); |
| 447 // The number of preconnect controllers. | 455 // The number of preconnect controllers. |
| 448 factory_dump->AddScalar("preconnect_count", | 456 factory_dump->AddScalar("preconnect_count", |
| 449 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 457 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 450 preconnect_controller_count); | 458 num_controllers_for_preconnect); |
| 451 } | 459 } |
| 452 | 460 |
| 453 } // namespace net | 461 } // namespace net |
| OLD | NEW |