Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 } | 306 } |
| 307 | 307 |
| 308 void MemoryDumpManager::RegisterDumpProviderInternal( | 308 void MemoryDumpManager::RegisterDumpProviderInternal( |
| 309 MemoryDumpProvider* mdp, | 309 MemoryDumpProvider* mdp, |
| 310 const char* name, | 310 const char* name, |
| 311 scoped_refptr<SequencedTaskRunner> task_runner, | 311 scoped_refptr<SequencedTaskRunner> task_runner, |
| 312 const MemoryDumpProvider::Options& options) { | 312 const MemoryDumpProvider::Options& options) { |
| 313 if (dumper_registrations_ignored_for_testing_) | 313 if (dumper_registrations_ignored_for_testing_) |
| 314 return; | 314 return; |
| 315 | 315 |
| 316 bool whitelisted_for_background_mode = IsMemoryDumpProviderWhitelisted(name); | 316 bool whitelisted_for_background_mode = IsMemoryDumpProviderWhitelisted(name); |
|
hjd
2017/05/10 13:48:08
Shall I rename all the methods/variables named thi
Primiano Tucci (use gerrit)
2017/05/10 16:18:58
up to you. I think is worth a comment, explaining
hjd
2017/05/15 12:02:27
Done.
| |
| 317 scoped_refptr<MemoryDumpProviderInfo> mdpinfo = | 317 bool whitelisted_for_summary_mode = |
| 318 new MemoryDumpProviderInfo(mdp, name, std::move(task_runner), options, | 318 IsMemoryDumpProviderWhitelistedForSummary(name); |
| 319 whitelisted_for_background_mode); | 319 |
| 320 scoped_refptr<MemoryDumpProviderInfo> mdpinfo = new MemoryDumpProviderInfo( | |
| 321 mdp, name, std::move(task_runner), options, | |
| 322 whitelisted_for_background_mode, whitelisted_for_summary_mode); | |
| 320 | 323 |
| 321 if (options.is_fast_polling_supported) { | 324 if (options.is_fast_polling_supported) { |
| 322 DCHECK(!mdpinfo->task_runner) << "MemoryDumpProviders capable of fast " | 325 DCHECK(!mdpinfo->task_runner) << "MemoryDumpProviders capable of fast " |
| 323 "polling must NOT be thread bound."; | 326 "polling must NOT be thread bound."; |
| 324 } | 327 } |
| 325 | 328 |
| 326 { | 329 { |
| 327 AutoLock lock(lock_); | 330 AutoLock lock(lock_); |
| 328 bool already_registered = !dump_providers_.insert(mdpinfo).second; | 331 bool already_registered = !dump_providers_.insert(mdpinfo).second; |
| 329 // This actually happens in some tests which don't have a clean tear-down | 332 // This actually happens in some tests which don't have a clean tear-down |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 | 552 |
| 550 // If we are in background tracing, we should invoke only the whitelisted | 553 // If we are in background tracing, we should invoke only the whitelisted |
| 551 // providers. Ignore other providers and continue. | 554 // providers. Ignore other providers and continue. |
| 552 if (pmd_async_state->req_args.level_of_detail == | 555 if (pmd_async_state->req_args.level_of_detail == |
| 553 MemoryDumpLevelOfDetail::BACKGROUND && | 556 MemoryDumpLevelOfDetail::BACKGROUND && |
| 554 !mdpinfo->whitelisted_for_background_mode) { | 557 !mdpinfo->whitelisted_for_background_mode) { |
| 555 pmd_async_state->pending_dump_providers.pop_back(); | 558 pmd_async_state->pending_dump_providers.pop_back(); |
| 556 return SetupNextMemoryDump(std::move(pmd_async_state)); | 559 return SetupNextMemoryDump(std::move(pmd_async_state)); |
| 557 } | 560 } |
| 558 | 561 |
| 562 // If we are in summary mode, we only need to invoke the providers | |
| 563 // whitelisted for summary mode. | |
| 564 if (pmd_async_state->req_args.dump_type == MemoryDumpType::SUMMARY_ONLY && | |
| 565 !mdpinfo->whitelisted_for_summary_mode) { | |
| 566 pmd_async_state->pending_dump_providers.pop_back(); | |
| 567 return SetupNextMemoryDump(std::move(pmd_async_state)); | |
| 568 } | |
| 569 | |
| 559 // If the dump provider did not specify a task runner affinity, dump on | 570 // If the dump provider did not specify a task runner affinity, dump on |
| 560 // |dump_thread_|. | 571 // |dump_thread_|. |
| 561 SequencedTaskRunner* task_runner = mdpinfo->task_runner.get(); | 572 SequencedTaskRunner* task_runner = mdpinfo->task_runner.get(); |
| 562 if (!task_runner) { | 573 if (!task_runner) { |
| 563 DCHECK(mdpinfo->options.dumps_on_single_thread_task_runner); | 574 DCHECK(mdpinfo->options.dumps_on_single_thread_task_runner); |
| 564 task_runner = pmd_async_state->dump_thread_task_runner.get(); | 575 task_runner = pmd_async_state->dump_thread_task_runner.get(); |
| 565 DCHECK(task_runner); | 576 DCHECK(task_runner); |
| 566 } | 577 } |
| 567 | 578 |
| 568 if (mdpinfo->options.dumps_on_single_thread_task_runner && | 579 if (mdpinfo->options.dumps_on_single_thread_task_runner && |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 if (iter == process_dumps.end()) { | 891 if (iter == process_dumps.end()) { |
| 881 std::unique_ptr<ProcessMemoryDump> new_pmd( | 892 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 882 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); | 893 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); |
| 883 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 894 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 884 } | 895 } |
| 885 return iter->second.get(); | 896 return iter->second.get(); |
| 886 } | 897 } |
| 887 | 898 |
| 888 } // namespace trace_event | 899 } // namespace trace_event |
| 889 } // namespace base | 900 } // namespace base |
| OLD | NEW |