| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 762 |
| 763 if (!pmd_async_state->callback.is_null()) { | 763 if (!pmd_async_state->callback.is_null()) { |
| 764 pmd_async_state->callback.Run(dump_guid, dump_successful, result); | 764 pmd_async_state->callback.Run(dump_guid, dump_successful, result); |
| 765 pmd_async_state->callback.Reset(); | 765 pmd_async_state->callback.Reset(); |
| 766 } | 766 } |
| 767 | 767 |
| 768 TRACE_EVENT_NESTABLE_ASYNC_END0(kTraceCategory, "ProcessMemoryDump", | 768 TRACE_EVENT_NESTABLE_ASYNC_END0(kTraceCategory, "ProcessMemoryDump", |
| 769 TRACE_ID_LOCAL(dump_guid)); | 769 TRACE_ID_LOCAL(dump_guid)); |
| 770 } | 770 } |
| 771 | 771 |
| 772 void MemoryDumpManager::Enable( | 772 void MemoryDumpManager::SetupForTracing( |
| 773 const TraceConfig::MemoryDumpConfig& memory_dump_config) { | 773 const TraceConfig::MemoryDumpConfig& memory_dump_config) { |
| 774 scoped_refptr<HeapProfilerSerializationState> | 774 scoped_refptr<HeapProfilerSerializationState> |
| 775 heap_profiler_serialization_state = new HeapProfilerSerializationState; | 775 heap_profiler_serialization_state = new HeapProfilerSerializationState; |
| 776 heap_profiler_serialization_state | 776 heap_profiler_serialization_state |
| 777 ->set_heap_profiler_breakdown_threshold_bytes( | 777 ->set_heap_profiler_breakdown_threshold_bytes( |
| 778 memory_dump_config.heap_profiler_options.breakdown_threshold_bytes); | 778 memory_dump_config.heap_profiler_options.breakdown_threshold_bytes); |
| 779 if (heap_profiling_enabled_) { | 779 if (heap_profiling_enabled_) { |
| 780 // If heap profiling is enabled, the stack frame deduplicator and type name | 780 // If heap profiling is enabled, the stack frame deduplicator and type name |
| 781 // deduplicator will be in use. Add a metadata events to write the frames | 781 // deduplicator will be in use. Add a metadata events to write the frames |
| 782 // and type IDs. | 782 // and type IDs. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 // Only coordinator process triggers periodic global memory dumps. | 847 // Only coordinator process triggers periodic global memory dumps. |
| 848 if (is_coordinator_ && !periodic_config.triggers.empty()) { | 848 if (is_coordinator_ && !periodic_config.triggers.empty()) { |
| 849 MemoryDumpScheduler::GetInstance()->Start(periodic_config, | 849 MemoryDumpScheduler::GetInstance()->Start(periodic_config, |
| 850 GetOrCreateBgTaskRunnerLocked()); | 850 GetOrCreateBgTaskRunnerLocked()); |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 | 853 |
| 854 void MemoryDumpManager::Disable() { | 854 void MemoryDumpManager::TeardownForTracing() { |
| 855 // There might be a memory dump in progress while this happens. Therefore, | 855 // There might be a memory dump in progress while this happens. Therefore, |
| 856 // ensure that the MDM state which depends on the tracing enabled / disabled | 856 // ensure that the MDM state which depends on the tracing enabled / disabled |
| 857 // state is always accessed by the dumping methods holding the |lock_|. | 857 // state is always accessed by the dumping methods holding the |lock_|. |
| 858 if (!subtle::NoBarrier_Load(&is_enabled_)) | 858 if (!subtle::NoBarrier_Load(&is_enabled_)) |
| 859 return; | 859 return; |
| 860 subtle::NoBarrier_Store(&is_enabled_, 0); | 860 subtle::NoBarrier_Store(&is_enabled_, 0); |
| 861 { | 861 { |
| 862 AutoLock lock(lock_); | 862 AutoLock lock(lock_); |
| 863 MemoryDumpScheduler::GetInstance()->Stop(); | 863 MemoryDumpScheduler::GetInstance()->Stop(); |
| 864 MemoryPeakDetector::GetInstance()->TearDown(); | 864 MemoryPeakDetector::GetInstance()->TearDown(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 894 if (iter == process_dumps.end()) { | 894 if (iter == process_dumps.end()) { |
| 895 std::unique_ptr<ProcessMemoryDump> new_pmd( | 895 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 896 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); | 896 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); |
| 897 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 897 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 898 } | 898 } |
| 899 return iter->second.get(); | 899 return iter->second.get(); |
| 900 } | 900 } |
| 901 | 901 |
| 902 } // namespace trace_event | 902 } // namespace trace_event |
| 903 } // namespace base | 903 } // namespace base |
| OLD | NEW |