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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (heap_profiling_enabled_) | 136 if (heap_profiling_enabled_) |
137 return; | 137 return; |
138 | 138 |
139 if (!CommandLine::InitializedForCurrentProcess() || | 139 if (!CommandLine::InitializedForCurrentProcess() || |
140 !CommandLine::ForCurrentProcess()->HasSwitch( | 140 !CommandLine::ForCurrentProcess()->HasSwitch( |
141 switches::kEnableHeapProfiling)) | 141 switches::kEnableHeapProfiling)) |
142 return; | 142 return; |
143 | 143 |
144 AllocationContextTracker::SetCaptureEnabled(true); | 144 AllocationContextTracker::SetCaptureEnabled(true); |
145 for (auto mdp : dump_providers_) | 145 for (auto mdp : dump_providers_) |
146 mdp->dump_provider->OnHeapProfilingEnabled(true); | 146 mdp->dump_provider->OnHeapProfilingEnabled(); |
147 heap_profiling_enabled_ = true; | 147 heap_profiling_enabled_ = true; |
148 } | 148 } |
149 | 149 |
150 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 150 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
151 bool is_coordinator) { | 151 bool is_coordinator) { |
152 { | 152 { |
153 AutoLock lock(lock_); | 153 AutoLock lock(lock_); |
154 DCHECK(delegate); | 154 DCHECK(delegate); |
155 DCHECK(!delegate_); | 155 DCHECK(!delegate_); |
156 delegate_ = delegate; | 156 delegate_ = delegate; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 { | 195 { |
196 AutoLock lock(lock_); | 196 AutoLock lock(lock_); |
197 bool already_registered = !dump_providers_.insert(mdpinfo).second; | 197 bool already_registered = !dump_providers_.insert(mdpinfo).second; |
198 // This actually happens in some tests which don't have a clean tear-down | 198 // This actually happens in some tests which don't have a clean tear-down |
199 // path for RenderThreadImpl::Init(). | 199 // path for RenderThreadImpl::Init(). |
200 if (already_registered) | 200 if (already_registered) |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 if (heap_profiling_enabled_) | 204 if (heap_profiling_enabled_) |
205 mdp->OnHeapProfilingEnabled(true); | 205 mdp->OnHeapProfilingEnabled(); |
206 } | 206 } |
207 | 207 |
208 void MemoryDumpManager::RegisterDumpProvider( | 208 void MemoryDumpManager::RegisterDumpProvider( |
209 MemoryDumpProvider* mdp, | 209 MemoryDumpProvider* mdp, |
210 const char* name, | 210 const char* name, |
211 const scoped_refptr<SingleThreadTaskRunner>& task_runner) { | 211 const scoped_refptr<SingleThreadTaskRunner>& task_runner) { |
212 RegisterDumpProvider(mdp, name, task_runner, MemoryDumpProvider::Options()); | 212 RegisterDumpProvider(mdp, name, task_runner, MemoryDumpProvider::Options()); |
213 } | 213 } |
214 | 214 |
215 void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) { | 215 void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 auto iter = process_dumps.find(pid); | 672 auto iter = process_dumps.find(pid); |
673 if (iter == process_dumps.end()) { | 673 if (iter == process_dumps.end()) { |
674 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); | 674 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); |
675 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 675 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
676 } | 676 } |
677 return iter->second.get(); | 677 return iter->second.get(); |
678 } | 678 } |
679 | 679 |
680 } // namespace trace_event | 680 } // namespace trace_event |
681 } // namespace base | 681 } // namespace base |
OLD | NEW |