1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "partition_alloc/starscan/pcscan.h" 6 7 #include "partition_alloc/partition_alloc_base/compiler_specific.h" 8 #include "partition_alloc/starscan/pcscan_internal.h" 9 10 namespace partition_alloc::internal { 11 Initialize(InitConfig config)12void PCScan::Initialize(InitConfig config) { 13 PCScanInternal::Instance().Initialize(config); 14 } 15 IsInitialized()16bool PCScan::IsInitialized() { 17 return PCScanInternal::Instance().is_initialized(); 18 } 19 Disable()20void PCScan::Disable() { 21 auto& instance = PCScan::Instance(); 22 instance.scheduler().scheduling_backend().DisableScheduling(); 23 } 24 IsEnabled()25bool PCScan::IsEnabled() { 26 auto& instance = PCScan::Instance(); 27 return instance.scheduler().scheduling_backend().is_scheduling_enabled(); 28 } 29 Reenable()30void PCScan::Reenable() { 31 auto& instance = PCScan::Instance(); 32 instance.scheduler().scheduling_backend().EnableScheduling(); 33 } 34 RegisterScannableRoot(Root * root)35void PCScan::RegisterScannableRoot(Root* root) { 36 PCScanInternal::Instance().RegisterScannableRoot(root); 37 } 38 RegisterNonScannableRoot(Root * root)39void PCScan::RegisterNonScannableRoot(Root* root) { 40 PCScanInternal::Instance().RegisterNonScannableRoot(root); 41 } 42 RegisterNewSuperPage(Root * root,uintptr_t super_page_base)43void PCScan::RegisterNewSuperPage(Root* root, uintptr_t super_page_base) { 44 PCScanInternal::Instance().RegisterNewSuperPage(root, super_page_base); 45 } 46 PerformScan(InvocationMode invocation_mode)47void PCScan::PerformScan(InvocationMode invocation_mode) { 48 PCScanInternal::Instance().PerformScan(invocation_mode); 49 } 50 PerformScanIfNeeded(InvocationMode invocation_mode)51void PCScan::PerformScanIfNeeded(InvocationMode invocation_mode) { 52 PCScanInternal::Instance().PerformScanIfNeeded(invocation_mode); 53 } 54 PerformDelayedScan(int64_t delay_in_microseconds)55void PCScan::PerformDelayedScan(int64_t delay_in_microseconds) { 56 PCScanInternal::Instance().PerformDelayedScan( 57 base::Microseconds(delay_in_microseconds)); 58 } 59 JoinScan()60void PCScan::JoinScan() { 61 PCScanInternal::Instance().JoinScan(); 62 } 63 SetProcessName(const char * process_name)64void PCScan::SetProcessName(const char* process_name) { 65 PCScanInternal::Instance().SetProcessName(process_name); 66 } 67 EnableStackScanning()68void PCScan::EnableStackScanning() { 69 PCScanInternal::Instance().EnableStackScanning(); 70 } DisableStackScanning()71void PCScan::DisableStackScanning() { 72 PCScanInternal::Instance().DisableStackScanning(); 73 } IsStackScanningEnabled()74bool PCScan::IsStackScanningEnabled() { 75 return PCScanInternal::Instance().IsStackScanningEnabled(); 76 } 77 EnableImmediateFreeing()78void PCScan::EnableImmediateFreeing() { 79 PCScanInternal::Instance().EnableImmediateFreeing(); 80 } 81 SetClearType(ClearType clear_type)82void PCScan::SetClearType(ClearType clear_type) { 83 PCScan& instance = Instance(); 84 instance.clear_type_ = clear_type; 85 } 86 UninitForTesting()87void PCScan::UninitForTesting() { 88 PCScanInternal::Instance().ClearRootsForTesting(); // IN-TEST 89 } 90 ReinitForTesting(InitConfig config)91void PCScan::ReinitForTesting(InitConfig config) { 92 PCScanInternal::Instance().ReinitForTesting(config); // IN-TEST 93 } 94 FinishScanForTesting()95void PCScan::FinishScanForTesting() { 96 PCScanInternal::Instance().FinishScanForTesting(); // IN-TEST 97 } 98 RegisterStatsReporter(partition_alloc::StatsReporter * reporter)99void PCScan::RegisterStatsReporter(partition_alloc::StatsReporter* reporter) { 100 PCScanInternal::Instance().RegisterStatsReporter(reporter); 101 } 102 103 PCScan PCScan::instance_ PA_CONSTINIT; 104 105 } // namespace partition_alloc::internal 106