| 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 <utility> |
| 8 |
| 7 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 9 #include "base/files/memory_mapped_file.h" | 11 #include "base/files/memory_mapped_file.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 14 | 16 |
| 15 namespace base { | 17 namespace base { |
| 16 namespace debug { | 18 namespace debug { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 47 for (auto& activity : activity_snapshot_.activity_stack) { | 49 for (auto& activity : activity_snapshot_.activity_stack) { |
| 48 // The global GetUserDataSnapshot will return an empty snapshot if the ref | 50 // The global GetUserDataSnapshot will return an empty snapshot if the ref |
| 49 // or id is not valid. | 51 // or id is not valid. |
| 50 activity_snapshot_.user_data_stack.push_back(global->GetUserDataSnapshot( | 52 activity_snapshot_.user_data_stack.push_back(global->GetUserDataSnapshot( |
| 51 activity.user_data_ref, activity.user_data_id)); | 53 activity.user_data_ref, activity.user_data_id)); |
| 52 } | 54 } |
| 53 } | 55 } |
| 54 | 56 |
| 55 GlobalActivityAnalyzer::GlobalActivityAnalyzer( | 57 GlobalActivityAnalyzer::GlobalActivityAnalyzer( |
| 56 std::unique_ptr<PersistentMemoryAllocator> allocator) | 58 std::unique_ptr<PersistentMemoryAllocator> allocator) |
| 57 : allocator_(std::move(allocator)), allocator_iterator_(allocator_.get()) {} | 59 : allocator_(std::move(allocator)), allocator_iterator_(allocator_.get()) { |
| 60 DCHECK(allocator_); |
| 61 } |
| 58 | 62 |
| 59 GlobalActivityAnalyzer::~GlobalActivityAnalyzer() {} | 63 GlobalActivityAnalyzer::~GlobalActivityAnalyzer() {} |
| 60 | 64 |
| 61 #if !defined(OS_NACL) | 65 #if !defined(OS_NACL) |
| 62 // static | 66 // static |
| 63 std::unique_ptr<GlobalActivityAnalyzer> GlobalActivityAnalyzer::CreateWithFile( | 67 std::unique_ptr<GlobalActivityAnalyzer> GlobalActivityAnalyzer::CreateWithFile( |
| 64 const FilePath& file_path) { | 68 const FilePath& file_path) { |
| 65 // Map the file read-write so it can guarantee consistency between | 69 // Map the file read-write so it can guarantee consistency between |
| 66 // the analyzer and any trackers that my still be active. | 70 // the analyzer and any trackers that my still be active. |
| 67 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); | 71 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // Add this analyzer to the map of known ones, indexed by a unique thread | 228 // Add this analyzer to the map of known ones, indexed by a unique thread |
| 225 // identifier. | 229 // identifier. |
| 226 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); | 230 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); |
| 227 analyzer->allocator_reference_ = ref; | 231 analyzer->allocator_reference_ = ref; |
| 228 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); | 232 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); |
| 229 } | 233 } |
| 230 } | 234 } |
| 231 | 235 |
| 232 } // namespace debug | 236 } // namespace debug |
| 233 } // namespace base | 237 } // namespace base |
| OLD | NEW |