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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 GlobalActivityAnalyzer::GetProcessDataSnapshot(int64_t pid) { | 165 GlobalActivityAnalyzer::GetProcessDataSnapshot(int64_t pid) { |
166 auto iter = process_data_.find(pid); | 166 auto iter = process_data_.find(pid); |
167 if (iter == process_data_.end()) | 167 if (iter == process_data_.end()) |
168 return g_empty_user_data_snapshot.Get(); | 168 return g_empty_user_data_snapshot.Get(); |
169 if (iter->second.create_stamp > analysis_stamp_) | 169 if (iter->second.create_stamp > analysis_stamp_) |
170 return g_empty_user_data_snapshot.Get(); | 170 return g_empty_user_data_snapshot.Get(); |
171 DCHECK_EQ(pid, iter->second.process_id); | 171 DCHECK_EQ(pid, iter->second.process_id); |
172 return iter->second.data; | 172 return iter->second.data; |
173 } | 173 } |
174 | 174 |
175 const ActivityUserData::Snapshot& | |
176 GlobalActivityAnalyzer::GetGlobalDataSnapshot() { | |
177 global_data_snapshot_.clear(); | |
178 | |
179 PersistentMemoryAllocator::Reference ref = | |
180 PersistentMemoryAllocator::Iterator(allocator_.get()) | |
181 .GetNextOfType(GlobalActivityTracker::kTypeIdGlobalDataRecord); | |
182 void* memory = allocator_->GetAsArray<char>( | |
183 ref, GlobalActivityTracker::kTypeIdGlobalDataRecord, | |
184 PersistentMemoryAllocator::kSizeAny); | |
185 if (memory) { | |
186 size_t size = allocator_->GetAllocSize(ref); | |
187 const ActivityUserData global_data(memory, size); | |
188 global_data.CreateSnapshot(&global_data_snapshot_); | |
189 } | |
190 | |
191 return global_data_snapshot_; | |
192 } | |
193 | |
194 std::vector<std::string> GlobalActivityAnalyzer::GetLogMessages() { | 175 std::vector<std::string> GlobalActivityAnalyzer::GetLogMessages() { |
195 std::vector<std::string> messages; | 176 std::vector<std::string> messages; |
196 PersistentMemoryAllocator::Reference ref; | 177 PersistentMemoryAllocator::Reference ref; |
197 | 178 |
198 PersistentMemoryAllocator::Iterator iter(allocator_.get()); | 179 PersistentMemoryAllocator::Iterator iter(allocator_.get()); |
199 while ((ref = iter.GetNextOfType( | 180 while ((ref = iter.GetNextOfType( |
200 GlobalActivityTracker::kTypeIdGlobalLogMessage)) != 0) { | 181 GlobalActivityTracker::kTypeIdGlobalLogMessage)) != 0) { |
201 const char* message = allocator_->GetAsArray<char>( | 182 const char* message = allocator_->GetAsArray<char>( |
202 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, | 183 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, |
203 PersistentMemoryAllocator::kSizeAny); | 184 PersistentMemoryAllocator::kSizeAny); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } break; | 320 } break; |
340 } | 321 } |
341 } | 322 } |
342 | 323 |
343 // Reverse the list of PIDs so that they get popped in the order found. | 324 // Reverse the list of PIDs so that they get popped in the order found. |
344 std::reverse(process_ids_.begin(), process_ids_.end()); | 325 std::reverse(process_ids_.begin(), process_ids_.end()); |
345 } | 326 } |
346 | 327 |
347 } // namespace debug | 328 } // namespace debug |
348 } // namespace base | 329 } // namespace base |
OLD | NEW |