Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 1559023002: [tracing] Make memory-infra unregristration DCHECK stricter Base URL: https://chromium.googlesource.com/chromium/src.git@mdm_delete_async
Patch Set: +browsertests Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698