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

Side by Side Diff: base/debug/activity_analyzer.cc

Issue 2387733002: Move memory management code into separate class for future reuse. (Closed)
Patch Set: use method for determining 'free' type Created 4 years, 2 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/debug/activity_tracker.h » ('j') | base/debug/activity_tracker.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/debug/activity_analyzer.h" 5 #include "base/debug/activity_analyzer.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/memory_mapped_file.h" 9 #include "base/files/memory_mapped_file.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 void GlobalActivityAnalyzer::PrepareAllAnalyzers() { 85 void GlobalActivityAnalyzer::PrepareAllAnalyzers() {
86 // Fetch all the records. This will retrieve only ones created since the 86 // Fetch all the records. This will retrieve only ones created since the
87 // last run since the PMA iterator will continue from where it left off. 87 // last run since the PMA iterator will continue from where it left off.
88 uint32_t type; 88 uint32_t type;
89 PersistentMemoryAllocator::Reference ref; 89 PersistentMemoryAllocator::Reference ref;
90 while ((ref = allocator_iterator_.GetNext(&type)) != 0) { 90 while ((ref = allocator_iterator_.GetNext(&type)) != 0) {
91 switch (type) { 91 switch (type) {
92 case GlobalActivityTracker::kTypeIdActivityTracker: 92 case GlobalActivityTracker::kTypeIdActivityTracker:
93 case GlobalActivityTracker::kTypeIdActivityTrackerFree: 93 case ~GlobalActivityTracker::kTypeIdActivityTracker:
Alexei Svitkine (slow) 2016/10/13 19:23:20 Nit: Can this also use the helper function? You ca
bcwhite 2016/10/13 19:35:13 How about if I just make the class take a "free ty
94 // Free or not, add it to the list of references for later analysis. 94 // Free or not, add it to the list of references for later analysis.
95 tracker_references_.insert(ref); 95 tracker_references_.insert(ref);
96 break; 96 break;
97 } 97 }
98 } 98 }
99 99
100 // Go through all the known references and create analyzers for them with 100 // Go through all the known references and create analyzers for them with
101 // snapshots of the current state. 101 // snapshots of the current state.
102 analyzers_.clear(); 102 analyzers_.clear();
103 for (PersistentMemoryAllocator::Reference tracker_ref : tracker_references_) { 103 for (PersistentMemoryAllocator::Reference tracker_ref : tracker_references_) {
(...skipping 15 matching lines...) Expand all
119 // Add this analyzer to the map of known ones, indexed by a unique thread 119 // Add this analyzer to the map of known ones, indexed by a unique thread
120 // identifier. 120 // identifier.
121 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); 121 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey()));
122 analyzer->allocator_reference_ = ref; 122 analyzer->allocator_reference_ = ref;
123 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); 123 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer);
124 } 124 }
125 } 125 }
126 126
127 } // namespace debug 127 } // namespace debug
128 } // namespace base 128 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/debug/activity_tracker.h » ('j') | base/debug/activity_tracker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698