| 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_tracker.h" | 5 #include "base/debug/activity_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 if (!tracker) | 1314 if (!tracker) |
| 1315 return nullptr; | 1315 return nullptr; |
| 1316 | 1316 |
| 1317 // Thread trackers assume that the global tracker is present for some | 1317 // Thread trackers assume that the global tracker is present for some |
| 1318 // operations so ensure that there aren't any. | 1318 // operations so ensure that there aren't any. |
| 1319 tracker->ReleaseTrackerForCurrentThreadForTesting(); | 1319 tracker->ReleaseTrackerForCurrentThreadForTesting(); |
| 1320 DCHECK_EQ(0, tracker->thread_tracker_count_.load(std::memory_order_relaxed)); | 1320 DCHECK_EQ(0, tracker->thread_tracker_count_.load(std::memory_order_relaxed)); |
| 1321 | 1321 |
| 1322 subtle::Release_Store(&g_tracker_, 0); | 1322 subtle::Release_Store(&g_tracker_, 0); |
| 1323 return WrapUnique(tracker); | 1323 return WrapUnique(tracker); |
| 1324 }; | 1324 } |
| 1325 | 1325 |
| 1326 ThreadActivityTracker* GlobalActivityTracker::CreateTrackerForCurrentThread() { | 1326 ThreadActivityTracker* GlobalActivityTracker::CreateTrackerForCurrentThread() { |
| 1327 DCHECK(!this_thread_tracker_.Get()); | 1327 DCHECK(!this_thread_tracker_.Get()); |
| 1328 | 1328 |
| 1329 PersistentMemoryAllocator::Reference mem_reference; | 1329 PersistentMemoryAllocator::Reference mem_reference; |
| 1330 | 1330 |
| 1331 { | 1331 { |
| 1332 base::AutoLock autolock(thread_tracker_allocator_lock_); | 1332 base::AutoLock autolock(thread_tracker_allocator_lock_); |
| 1333 mem_reference = thread_tracker_allocator_.GetObjectReference(); | 1333 mem_reference = thread_tracker_allocator_.GetObjectReference(); |
| 1334 } | 1334 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 allocator_->MakeIterable(record); | 1594 allocator_->MakeIterable(record); |
| 1595 modules_.insert(std::make_pair(info.file, record)); | 1595 modules_.insert(std::make_pair(info.file, record)); |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 void GlobalActivityTracker::RecordFieldTrial(const std::string& trial_name, | 1598 void GlobalActivityTracker::RecordFieldTrial(const std::string& trial_name, |
| 1599 StringPiece group_name) { | 1599 StringPiece group_name) { |
| 1600 const std::string key = std::string("FieldTrial.") + trial_name; | 1600 const std::string key = std::string("FieldTrial.") + trial_name; |
| 1601 process_data_.SetString(key, group_name); | 1601 process_data_.SetString(key, group_name); |
| 1602 } | 1602 } |
| 1603 | 1603 |
| 1604 void GlobalActivityTracker::MarkDeleted() { |
| 1605 allocator_->SetMemoryState(PersistentMemoryAllocator::MEMORY_DELETED); |
| 1606 } |
| 1607 |
| 1604 GlobalActivityTracker::GlobalActivityTracker( | 1608 GlobalActivityTracker::GlobalActivityTracker( |
| 1605 std::unique_ptr<PersistentMemoryAllocator> allocator, | 1609 std::unique_ptr<PersistentMemoryAllocator> allocator, |
| 1606 int stack_depth, | 1610 int stack_depth, |
| 1607 int64_t process_id) | 1611 int64_t process_id) |
| 1608 : allocator_(std::move(allocator)), | 1612 : allocator_(std::move(allocator)), |
| 1609 stack_memory_size_(ThreadActivityTracker::SizeForStackDepth(stack_depth)), | 1613 stack_memory_size_(ThreadActivityTracker::SizeForStackDepth(stack_depth)), |
| 1610 process_id_(process_id == 0 ? GetCurrentProcId() : process_id), | 1614 process_id_(process_id == 0 ? GetCurrentProcId() : process_id), |
| 1611 this_thread_tracker_(&OnTLSDestroy), | 1615 this_thread_tracker_(&OnTLSDestroy), |
| 1612 thread_tracker_count_(0), | 1616 thread_tracker_count_(0), |
| 1613 thread_tracker_allocator_(allocator_.get(), | 1617 thread_tracker_allocator_(allocator_.get(), |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 : GlobalActivityTracker::ScopedThreadActivity( | 1777 : GlobalActivityTracker::ScopedThreadActivity( |
| 1774 program_counter, | 1778 program_counter, |
| 1775 nullptr, | 1779 nullptr, |
| 1776 Activity::ACT_PROCESS_WAIT, | 1780 Activity::ACT_PROCESS_WAIT, |
| 1777 ActivityData::ForProcess(process->Pid()), | 1781 ActivityData::ForProcess(process->Pid()), |
| 1778 /*lock_allowed=*/true) {} | 1782 /*lock_allowed=*/true) {} |
| 1779 #endif | 1783 #endif |
| 1780 | 1784 |
| 1781 } // namespace debug | 1785 } // namespace debug |
| 1782 } // namespace base | 1786 } // namespace base |
| OLD | NEW |