| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 if (mdp_iter == dump_providers_.end()) | 243 if (mdp_iter == dump_providers_.end()) |
| 244 return; // Not registered / already unregistered. | 244 return; // Not registered / already unregistered. |
| 245 | 245 |
| 246 if (take_mdp_ownership_and_delete_async) { | 246 if (take_mdp_ownership_and_delete_async) { |
| 247 // The MDP will be deleted whenever the MDPInfo struct will, that is either: | 247 // The MDP will be deleted whenever the MDPInfo struct will, that is either: |
| 248 // - At the end of this function, if no dump is in progress. | 248 // - At the end of this function, if no dump is in progress. |
| 249 // - In the prologue of the ContinueAsyncProcessDump(). | 249 // - In the prologue of the ContinueAsyncProcessDump(). |
| 250 DCHECK(!(*mdp_iter)->owned_dump_provider); | 250 DCHECK(!(*mdp_iter)->owned_dump_provider); |
| 251 (*mdp_iter)->owned_dump_provider = std::move(owned_mdp); | 251 (*mdp_iter)->owned_dump_provider = std::move(owned_mdp); |
| 252 } else if (subtle::NoBarrier_Load(&memory_tracing_enabled_)) { | 252 } else { |
| 253 // If you hit this DCHECK, your dump provider has a bug. | 253 // If you hit this DCHECK, your dump provider has a bug. |
| 254 // Unregistration of a MemoryDumpProvider is safe only if: | 254 // Unregistration of a MemoryDumpProvider is safe only if: |
| 255 // - The MDP has specified a thread affinity (via task_runner()) AND | 255 // - The MDP has specified a thread affinity (via task_runner()) AND |
| 256 // the unregistration happens on the same thread (so the MDP cannot | 256 // the unregistration happens on the same thread (so the MDP cannot |
| 257 // unregister and be in the middle of a OnMemoryDump() at the same time. | 257 // unregister and be in the middle of a OnMemoryDump() at the same time. |
| 258 // - The MDP has NOT specified a thread affinity and its ownership is | 258 // - The MDP has NOT specified a thread affinity and its ownership is |
| 259 // transferred via UnregisterAndDeleteDumpProviderSoon(). | 259 // transferred via UnregisterAndDeleteDumpProviderSoon(). |
| 260 // In all the other cases, it is not possible to guarantee that the | 260 // In all the other cases, it is not possible to guarantee that the |
| 261 // unregistration will not race with OnMemoryDump() calls. | 261 // unregistration will not race with OnMemoryDump() calls. |
| 262 DCHECK((*mdp_iter)->task_runner && | 262 DCHECK((*mdp_iter)->task_runner && |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 auto iter = process_dumps.find(pid); | 655 auto iter = process_dumps.find(pid); |
| 656 if (iter == process_dumps.end()) { | 656 if (iter == process_dumps.end()) { |
| 657 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); | 657 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); |
| 658 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 658 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 659 } | 659 } |
| 660 return iter->second.get(); | 660 return iter->second.get(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 } // namespace trace_event | 663 } // namespace trace_event |
| 664 } // namespace base | 664 } // namespace base |
| OLD | NEW |