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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 dumper_registrations_ignored_for_testing_(false), | 166 dumper_registrations_ignored_for_testing_(false), |
167 heap_profiling_enabled_(false) { | 167 heap_profiling_enabled_(false) { |
168 g_next_guid.GetNext(); // Make sure that first guid is not zero. | 168 g_next_guid.GetNext(); // Make sure that first guid is not zero. |
169 | 169 |
170 // At this point the command line may not be initialized but we try to | 170 // At this point the command line may not be initialized but we try to |
171 // enable the heap profiler to capture allocations as soon as possible. | 171 // enable the heap profiler to capture allocations as soon as possible. |
172 EnableHeapProfilingIfNeeded(); | 172 EnableHeapProfilingIfNeeded(); |
173 } | 173 } |
174 | 174 |
175 MemoryDumpManager::~MemoryDumpManager() { | 175 MemoryDumpManager::~MemoryDumpManager() { |
176 AutoLock lock(lock_); | 176 Thread* dump_thread = nullptr; |
177 if (dump_thread_) { | 177 { |
178 dump_thread_->Stop(); | 178 AutoLock lock(lock_); |
179 if (dump_thread_) { | |
180 dump_thread = dump_thread_.get(); | |
181 } | |
182 } | |
183 if (dump_thread) { | |
184 dump_thread->Stop(); | |
185 } | |
186 { | |
Primiano Tucci (use gerrit)
2017/05/11 13:53:27
no need for these extra set of braces here
hjd
2017/05/11 14:18:41
Done.
| |
187 AutoLock lock(lock_); | |
179 dump_thread_.reset(); | 188 dump_thread_.reset(); |
180 } | 189 } |
181 } | 190 } |
182 | 191 |
183 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { | 192 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |
184 if (heap_profiling_enabled_) | 193 if (heap_profiling_enabled_) |
185 return; | 194 return; |
186 | 195 |
187 if (!CommandLine::InitializedForCurrentProcess() || | 196 if (!CommandLine::InitializedForCurrentProcess() || |
188 !CommandLine::ForCurrentProcess()->HasSwitch( | 197 !CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
880 if (iter == process_dumps.end()) { | 889 if (iter == process_dumps.end()) { |
881 std::unique_ptr<ProcessMemoryDump> new_pmd( | 890 std::unique_ptr<ProcessMemoryDump> new_pmd( |
882 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); | 891 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); |
883 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 892 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
884 } | 893 } |
885 return iter->second.get(); | 894 return iter->second.get(); |
886 } | 895 } |
887 | 896 |
888 } // namespace trace_event | 897 } // namespace trace_event |
889 } // namespace base | 898 } // namespace base |
OLD | NEW |