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 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 if (mdp_iter == dump_providers_.end()) | 200 if (mdp_iter == dump_providers_.end()) |
201 return; | 201 return; |
202 | 202 |
203 // Unregistration of a MemoryDumpProvider while tracing is ongoing is safe | 203 // Unregistration of a MemoryDumpProvider while tracing is ongoing is safe |
204 // only if the MDP has specified a thread affinity (via task_runner()) AND | 204 // only if the MDP has specified a thread affinity (via task_runner()) AND |
205 // the unregistration happens on the same thread (so the MDP cannot unregister | 205 // the unregistration happens on the same thread (so the MDP cannot unregister |
206 // and OnMemoryDump() at the same time). | 206 // and OnMemoryDump() at the same time). |
207 // Otherwise, it is not possible to guarantee that its unregistration is | 207 // Otherwise, it is not possible to guarantee that its unregistration is |
208 // race-free. If you hit this DCHECK, your MDP has a bug. | 208 // race-free. If you hit this DCHECK, your MDP has a bug. |
209 DCHECK_IMPLIES( | 209 DCHECK(!subtle::NoBarrier_Load(&memory_tracing_enabled_) || |
210 subtle::NoBarrier_Load(&memory_tracing_enabled_), | 210 (mdp_iter->task_runner && |
211 mdp_iter->task_runner && mdp_iter->task_runner->BelongsToCurrentThread()) | 211 mdp_iter->task_runner->BelongsToCurrentThread())) |
212 << "The MemoryDumpProvider attempted to unregister itself in a racy way. " | 212 << "The MemoryDumpProvider attempted to unregister itself in a racy way. " |
213 << "Please file a crbug."; | 213 << "Please file a crbug."; |
214 | 214 |
215 mdp_iter->unregistered = true; | 215 mdp_iter->unregistered = true; |
216 } | 216 } |
217 | 217 |
218 void MemoryDumpManager::RequestGlobalDump( | 218 void MemoryDumpManager::RequestGlobalDump( |
219 MemoryDumpType dump_type, | 219 MemoryDumpType dump_type, |
220 MemoryDumpLevelOfDetail level_of_detail, | 220 MemoryDumpLevelOfDetail level_of_detail, |
221 const MemoryDumpCallback& callback) { | 221 const MemoryDumpCallback& callback) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 next_dump_provider(next_dump_provider), | 529 next_dump_provider(next_dump_provider), |
530 callback(callback), | 530 callback(callback), |
531 task_runner(MessageLoop::current()->task_runner()) { | 531 task_runner(MessageLoop::current()->task_runner()) { |
532 } | 532 } |
533 | 533 |
534 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { | 534 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { |
535 } | 535 } |
536 | 536 |
537 } // namespace trace_event | 537 } // namespace trace_event |
538 } // namespace base | 538 } // namespace base |
OLD | NEW |