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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (it == dump_providers_.end()) | 219 if (it == dump_providers_.end()) |
220 return; | 220 return; |
221 | 221 |
222 const MemoryDumpProviderInfo& mdp_info = it->second; | 222 const MemoryDumpProviderInfo& mdp_info = it->second; |
223 // Unregistration of a MemoryDumpProvider while tracing is ongoing is safe | 223 // Unregistration of a MemoryDumpProvider while tracing is ongoing is safe |
224 // only if the MDP has specified a thread affinity (via task_runner()) AND | 224 // only if the MDP has specified a thread affinity (via task_runner()) AND |
225 // the unregistration happens on the same thread (so the MDP cannot unregister | 225 // the unregistration happens on the same thread (so the MDP cannot unregister |
226 // and OnMemoryDump() at the same time). | 226 // and OnMemoryDump() at the same time). |
227 // Otherwise, it is not possible to guarantee that its unregistration is | 227 // Otherwise, it is not possible to guarantee that its unregistration is |
228 // race-free. If you hit this DCHECK, your MDP has a bug. | 228 // race-free. If you hit this DCHECK, your MDP has a bug. |
229 DCHECK_IMPLIES( | 229 DCHECK( |
230 subtle::NoBarrier_Load(&memory_tracing_enabled_), | 230 !subtle::NoBarrier_Load(&memory_tracing_enabled_) || |
231 mdp_info.task_runner && mdp_info.task_runner->BelongsToCurrentThread()) | 231 (mdp_info.task_runner && mdp_info.task_runner->BelongsToCurrentThread())) |
232 << "The MemoryDumpProvider attempted to unregister itself in a racy way. " | 232 << "The MemoryDumpProvider attempted to unregister itself in a racy way. " |
233 << " Please file a crbug."; | 233 << " Please file a crbug."; |
234 | 234 |
235 // Remove from the enabled providers list. This is to deal with the case that | 235 // Remove from the enabled providers list. This is to deal with the case that |
236 // UnregisterDumpProvider is called while the trace is enabled. | 236 // UnregisterDumpProvider is called while the trace is enabled. |
237 dump_providers_.erase(it); | 237 dump_providers_.erase(it); |
238 } | 238 } |
239 | 239 |
240 void MemoryDumpManager::RequestGlobalDump( | 240 void MemoryDumpManager::RequestGlobalDump( |
241 MemoryDumpType dump_type, | 241 MemoryDumpType dump_type, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( | 451 MemoryDumpManager::MemoryDumpProviderInfo::MemoryDumpProviderInfo( |
452 const scoped_refptr<SingleThreadTaskRunner>& task_runner) | 452 const scoped_refptr<SingleThreadTaskRunner>& task_runner) |
453 : task_runner(task_runner), consecutive_failures(0), disabled(false) { | 453 : task_runner(task_runner), consecutive_failures(0), disabled(false) { |
454 } | 454 } |
455 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { | 455 MemoryDumpManager::MemoryDumpProviderInfo::~MemoryDumpProviderInfo() { |
456 } | 456 } |
457 | 457 |
458 } // namespace trace_event | 458 } // namespace trace_event |
459 } // namespace base | 459 } // namespace base |
OLD | NEW |