| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (!global_tracker) | 67 if (!global_tracker) |
| 68 return 0; | 68 return 0; |
| 69 return global_tracker->thread_tracker_count_.load( | 69 return global_tracker->thread_tracker_count_.load( |
| 70 std::memory_order_relaxed); | 70 std::memory_order_relaxed); |
| 71 } | 71 } |
| 72 | 72 |
| 73 size_t GetGlobalInactiveTrackerCount() { | 73 size_t GetGlobalInactiveTrackerCount() { |
| 74 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get(); | 74 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get(); |
| 75 if (!global_tracker) | 75 if (!global_tracker) |
| 76 return 0; | 76 return 0; |
| 77 return global_tracker->available_memories_.used(); | 77 return global_tracker->thread_tracker_allocator_.cache_used(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 static void DoNothing() {} | 80 static void DoNothing() {} |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 TEST_F(ActivityTrackerTest, PushPopTest) { | 83 TEST_F(ActivityTrackerTest, PushPopTest) { |
| 84 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker(); | 84 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker(); |
| 85 ActivitySnapshot snapshot; | 85 ActivitySnapshot snapshot; |
| 86 | 86 |
| 87 ASSERT_TRUE(tracker->Snapshot(&snapshot)); | 87 ASSERT_TRUE(tracker->Snapshot(&snapshot)); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 EXPECT_EQ(starting_inactive, GetGlobalInactiveTrackerCount()); | 281 EXPECT_EQ(starting_inactive, GetGlobalInactiveTrackerCount()); |
| 282 | 282 |
| 283 t2.Exit(); | 283 t2.Exit(); |
| 284 t2.Join(); | 284 t2.Join(); |
| 285 EXPECT_EQ(starting_active, GetGlobalActiveTrackerCount()); | 285 EXPECT_EQ(starting_active, GetGlobalActiveTrackerCount()); |
| 286 EXPECT_EQ(starting_inactive + 1, GetGlobalInactiveTrackerCount()); | 286 EXPECT_EQ(starting_inactive + 1, GetGlobalInactiveTrackerCount()); |
| 287 } | 287 } |
| 288 | 288 |
| 289 } // namespace debug | 289 } // namespace debug |
| 290 } // namespace base | 290 } // namespace base |
| OLD | NEW |