| 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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 allocator_->Allocate(kGlobalDataSize, kTypeIdGlobalDataRecord), | 1253 allocator_->Allocate(kGlobalDataSize, kTypeIdGlobalDataRecord), |
| 1254 kTypeIdGlobalDataRecord, | 1254 kTypeIdGlobalDataRecord, |
| 1255 PersistentMemoryAllocator::kSizeAny), | 1255 PersistentMemoryAllocator::kSizeAny), |
| 1256 kGlobalDataSize) { | 1256 kGlobalDataSize) { |
| 1257 // Ensure the passed memory is valid and empty (iterator finds nothing). | 1257 // Ensure the passed memory is valid and empty (iterator finds nothing). |
| 1258 uint32_t type; | 1258 uint32_t type; |
| 1259 DCHECK(!PersistentMemoryAllocator::Iterator(allocator_.get()).GetNext(&type)); | 1259 DCHECK(!PersistentMemoryAllocator::Iterator(allocator_.get()).GetNext(&type)); |
| 1260 | 1260 |
| 1261 // Ensure that there is no other global object and then make this one such. | 1261 // Ensure that there is no other global object and then make this one such. |
| 1262 DCHECK(!g_tracker_); | 1262 DCHECK(!g_tracker_); |
| 1263 subtle::NoBarrier_Store(&g_tracker_, reinterpret_cast<uintptr_t>(this)); | 1263 subtle::Release_Store(&g_tracker_, reinterpret_cast<uintptr_t>(this)); |
| 1264 | 1264 |
| 1265 // The global records must be iterable in order to be found by an analyzer. | 1265 // The global records must be iterable in order to be found by an analyzer. |
| 1266 allocator_->MakeIterable(allocator_->GetAsReference( | 1266 allocator_->MakeIterable(allocator_->GetAsReference( |
| 1267 global_data_.GetBaseAddress(), kTypeIdGlobalDataRecord)); | 1267 global_data_.GetBaseAddress(), kTypeIdGlobalDataRecord)); |
| 1268 | 1268 |
| 1269 // Fetch and record all activated field trials. | 1269 // Fetch and record all activated field trials. |
| 1270 FieldTrial::ActiveGroups active_groups; | 1270 FieldTrial::ActiveGroups active_groups; |
| 1271 FieldTrialList::GetActiveFieldTrialGroups(&active_groups); | 1271 FieldTrialList::GetActiveFieldTrialGroups(&active_groups); |
| 1272 for (auto& group : active_groups) | 1272 for (auto& group : active_groups) |
| 1273 RecordFieldTrial(group.trial_name, group.group_name); | 1273 RecordFieldTrial(group.trial_name, group.group_name); |
| 1274 } | 1274 } |
| 1275 | 1275 |
| 1276 GlobalActivityTracker::~GlobalActivityTracker() { | 1276 GlobalActivityTracker::~GlobalActivityTracker() { |
| 1277 DCHECK_EQ(Get(), this); | 1277 DCHECK_EQ(Get(), this); |
| 1278 DCHECK_EQ(0, thread_tracker_count_.load(std::memory_order_relaxed)); | 1278 DCHECK_EQ(0, thread_tracker_count_.load(std::memory_order_relaxed)); |
| 1279 subtle::NoBarrier_Store(&g_tracker_, 0); | 1279 subtle::Release_Store(&g_tracker_, 0); |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 void GlobalActivityTracker::ReturnTrackerMemory( | 1282 void GlobalActivityTracker::ReturnTrackerMemory( |
| 1283 ManagedActivityTracker* tracker) { | 1283 ManagedActivityTracker* tracker) { |
| 1284 PersistentMemoryAllocator::Reference mem_reference = tracker->mem_reference_; | 1284 PersistentMemoryAllocator::Reference mem_reference = tracker->mem_reference_; |
| 1285 void* mem_base = tracker->mem_base_; | 1285 void* mem_base = tracker->mem_base_; |
| 1286 DCHECK(mem_reference); | 1286 DCHECK(mem_reference); |
| 1287 DCHECK(mem_base); | 1287 DCHECK(mem_base); |
| 1288 | 1288 |
| 1289 // Remove the destructed tracker from the set of known ones. | 1289 // Remove the destructed tracker from the set of known ones. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 : GlobalActivityTracker::ScopedThreadActivity( | 1378 : GlobalActivityTracker::ScopedThreadActivity( |
| 1379 program_counter, | 1379 program_counter, |
| 1380 nullptr, | 1380 nullptr, |
| 1381 Activity::ACT_PROCESS_WAIT, | 1381 Activity::ACT_PROCESS_WAIT, |
| 1382 ActivityData::ForProcess(process->Pid()), | 1382 ActivityData::ForProcess(process->Pid()), |
| 1383 /*lock_allowed=*/true) {} | 1383 /*lock_allowed=*/true) {} |
| 1384 #endif | 1384 #endif |
| 1385 | 1385 |
| 1386 } // namespace debug | 1386 } // namespace debug |
| 1387 } // namespace base | 1387 } // namespace base |
| OLD | NEW |