Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |