| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { | 163 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |
| 164 if (heap_profiling_enabled_) | 164 if (heap_profiling_enabled_) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 if (!CommandLine::InitializedForCurrentProcess() || | 167 if (!CommandLine::InitializedForCurrentProcess() || |
| 168 !CommandLine::ForCurrentProcess()->HasSwitch( | 168 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 169 switches::kEnableHeapProfiling)) | 169 switches::kEnableHeapProfiling)) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 AllocationContextTracker::SetCaptureEnabled(true); | 172 std::string profiling_mode = CommandLine::ForCurrentProcess() |
| 173 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); |
| 174 AllocationContextTracker::SetCaptureMode( |
| 175 profiling_mode == switches::kEnableHeapProfilingModeNative ? |
| 176 AllocationContextTracker::CAPTURE_NATIVE_STACK : |
| 177 AllocationContextTracker::CAPTURE_PSEUDO_STACK); |
| 178 |
| 173 for (auto mdp : dump_providers_) | 179 for (auto mdp : dump_providers_) |
| 174 mdp->dump_provider->OnHeapProfilingEnabled(true); | 180 mdp->dump_provider->OnHeapProfilingEnabled(true); |
| 175 heap_profiling_enabled_ = true; | 181 heap_profiling_enabled_ = true; |
| 176 } | 182 } |
| 177 | 183 |
| 178 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 184 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
| 179 bool is_coordinator) { | 185 bool is_coordinator) { |
| 180 { | 186 { |
| 181 AutoLock lock(lock_); | 187 AutoLock lock(lock_); |
| 182 DCHECK(delegate); | 188 DCHECK(delegate); |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 if (iter == process_dumps.end()) { | 759 if (iter == process_dumps.end()) { |
| 754 std::unique_ptr<ProcessMemoryDump> new_pmd( | 760 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 755 new ProcessMemoryDump(session_state)); | 761 new ProcessMemoryDump(session_state)); |
| 756 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 762 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 757 } | 763 } |
| 758 return iter->second.get(); | 764 return iter->second.get(); |
| 759 } | 765 } |
| 760 | 766 |
| 761 } // namespace trace_event | 767 } // namespace trace_event |
| 762 } // namespace base | 768 } // namespace base |
| OLD | NEW |