[PA] Namespace migration (40 of N)
This change erases multiple `base::` aliases from PartitionAlloc
headers.
Bug: 1288247
Change-Id: I7eb4b10e251521aaae52528b3b09db0d49cdd4c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3722838
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Commit-Queue: Kalvin Lee <kdlee@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1019419}
NOKEYCHECK=True
GitOrigin-RevId: 9833bf903aed41264ba97975641cdd8b7f2d1ae0
diff --git a/allocator/allocator_shim.h b/allocator/allocator_shim.h
index f16d2d5..43bba50 100644
--- a/allocator/allocator_shim.h
+++ b/allocator/allocator_shim.h
@@ -192,7 +192,7 @@
AlternateBucketDistribution use_alternate_bucket_distribution);
#if defined(PA_ALLOW_PCSCAN)
-BASE_EXPORT void EnablePCScan(base::internal::PCScan::InitConfig);
+BASE_EXPORT void EnablePCScan(partition_alloc::internal::PCScan::InitConfig);
#endif
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
diff --git a/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc b/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc
index dfac7a9..da7dc93 100644
--- a/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc
+++ b/allocator/allocator_shim_default_dispatch_to_partition_alloc.cc
@@ -663,16 +663,18 @@
}
#if defined(PA_ALLOW_PCSCAN)
-void EnablePCScan(base::internal::PCScan::InitConfig config) {
+void EnablePCScan(partition_alloc::internal::PCScan::InitConfig config) {
partition_alloc::internal::base::PlatformThread::SetThreadNameHook(
&::base::PlatformThread::SetName);
- internal::PCScan::Initialize(config);
+ partition_alloc::internal::PCScan::Initialize(config);
- internal::PCScan::RegisterScannableRoot(Allocator());
+ partition_alloc::internal::PCScan::RegisterScannableRoot(Allocator());
if (OriginalAllocator() != nullptr)
- internal::PCScan::RegisterScannableRoot(OriginalAllocator());
+ partition_alloc::internal::PCScan::RegisterScannableRoot(
+ OriginalAllocator());
if (Allocator() != AlignedAllocator())
- internal::PCScan::RegisterScannableRoot(AlignedAllocator());
+ partition_alloc::internal::PCScan::RegisterScannableRoot(
+ AlignedAllocator());
internal::NonScannableAllocator::Instance().NotifyPCScanEnabled();
internal::NonQuarantinableAllocator::Instance().NotifyPCScanEnabled();
diff --git a/allocator/partition_alloc_support.cc b/allocator/partition_alloc_support.cc
index 4be5ff7..eba11bb 100644
--- a/allocator/partition_alloc_support.cc
+++ b/allocator/partition_alloc_support.cc
@@ -50,33 +50,33 @@
#if BUILDFLAG(ENABLE_BASE_TRACING)
constexpr const char* ScannerIdToTracingString(
- internal::StatsCollector::ScannerId id) {
+ partition_alloc::internal::StatsCollector::ScannerId id) {
switch (id) {
- case internal::StatsCollector::ScannerId::kClear:
+ case partition_alloc::internal::StatsCollector::ScannerId::kClear:
return "PCScan.Scanner.Clear";
- case internal::StatsCollector::ScannerId::kScan:
+ case partition_alloc::internal::StatsCollector::ScannerId::kScan:
return "PCScan.Scanner.Scan";
- case internal::StatsCollector::ScannerId::kSweep:
+ case partition_alloc::internal::StatsCollector::ScannerId::kSweep:
return "PCScan.Scanner.Sweep";
- case internal::StatsCollector::ScannerId::kOverall:
+ case partition_alloc::internal::StatsCollector::ScannerId::kOverall:
return "PCScan.Scanner";
- case internal::StatsCollector::ScannerId::kNumIds:
+ case partition_alloc::internal::StatsCollector::ScannerId::kNumIds:
__builtin_unreachable();
}
}
constexpr const char* MutatorIdToTracingString(
- internal::StatsCollector::MutatorId id) {
+ partition_alloc::internal::StatsCollector::MutatorId id) {
switch (id) {
- case internal::StatsCollector::MutatorId::kClear:
+ case partition_alloc::internal::StatsCollector::MutatorId::kClear:
return "PCScan.Mutator.Clear";
- case internal::StatsCollector::MutatorId::kScanStack:
+ case partition_alloc::internal::StatsCollector::MutatorId::kScanStack:
return "PCScan.Mutator.ScanStack";
- case internal::StatsCollector::MutatorId::kScan:
+ case partition_alloc::internal::StatsCollector::MutatorId::kScan:
return "PCScan.Mutator.Scan";
- case internal::StatsCollector::MutatorId::kOverall:
+ case partition_alloc::internal::StatsCollector::MutatorId::kOverall:
return "PCScan.Mutator";
- case internal::StatsCollector::MutatorId::kNumIds:
+ case partition_alloc::internal::StatsCollector::MutatorId::kNumIds:
__builtin_unreachable();
}
}
@@ -85,7 +85,7 @@
// Inject TRACE_EVENT_BEGIN/END, TRACE_COUNTER1, and UmaHistogramTimes.
class StatsReporterImpl final : public partition_alloc::StatsReporter {
public:
- void ReportTraceEvent(internal::StatsCollector::ScannerId id,
+ void ReportTraceEvent(partition_alloc::internal::StatsCollector::ScannerId id,
[[maybe_unused]] uint32_t tid,
int64_t start_time_ticks_internal_value,
int64_t end_time_ticks_internal_value) override {
@@ -104,7 +104,7 @@
#endif // BUILDFLAG(ENABLE_BASE_TRACING)
}
- void ReportTraceEvent(internal::StatsCollector::MutatorId id,
+ void ReportTraceEvent(partition_alloc::internal::StatsCollector::MutatorId id,
[[maybe_unused]] uint32_t tid,
int64_t start_time_ticks_internal_value,
int64_t end_time_ticks_internal_value) override {
@@ -156,7 +156,7 @@
DCHECK(!registered);
- internal::PCScan::RegisterStatsReporter(&s_reporter);
+ partition_alloc::internal::PCScan::RegisterStatsReporter(&s_reporter);
registered = true;
}
#endif // defined(PA_ALLOW_PCSCAN)
diff --git a/allocator/partition_allocator/partition_bucket.cc b/allocator/partition_allocator/partition_bucket.cc
index 36c7b43..13efed6 100644
--- a/allocator/partition_allocator/partition_bucket.cc
+++ b/allocator/partition_allocator/partition_bucket.cc
@@ -803,7 +803,7 @@
PageAccessibilityConfiguration::kReadWrite,
PageAccessibilityDisposition::kRequireUpdate);
}
- ::base::internal::PCScan::RegisterNewSuperPage(root, super_page);
+ PCScan::RegisterNewSuperPage(root, super_page);
}
return payload;
diff --git a/allocator/partition_allocator/starscan/metadata_allocator.h b/allocator/partition_allocator/starscan/metadata_allocator.h
index ddde016..fd95176 100644
--- a/allocator/partition_allocator/starscan/metadata_allocator.h
+++ b/allocator/partition_allocator/starscan/metadata_allocator.h
@@ -80,16 +80,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove these when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::AllocatedOnPCScanMetadataPartition;
-using ::partition_alloc::internal::MakePCScanMetadata;
-using ::partition_alloc::internal::MetadataAllocator;
-using ::partition_alloc::internal::PCScanMetadataAllocator;
-using ::partition_alloc::internal::PCScanMetadataDeleter;
-using ::partition_alloc::internal::ReinitPCScanMetadataAllocatorForTesting;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_METADATA_ALLOCATOR_H_
diff --git a/allocator/partition_allocator/starscan/pcscan.h b/allocator/partition_allocator/starscan/pcscan.h
index 13a0c3f..8f26105 100644
--- a/allocator/partition_allocator/starscan/pcscan.h
+++ b/allocator/partition_allocator/starscan/pcscan.h
@@ -281,10 +281,4 @@
} // namespace internal
} // namespace partition_alloc
-// TODO(crbug.com/1288247): Remove this when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::PCScan;
-
-} // namespace base::internal
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_PCSCAN_H_
diff --git a/allocator/partition_allocator/starscan/pcscan_internal.h b/allocator/partition_allocator/starscan/pcscan_internal.h
index 8c1c5ae..d016f83 100644
--- a/allocator/partition_allocator/starscan/pcscan_internal.h
+++ b/allocator/partition_allocator/starscan/pcscan_internal.h
@@ -20,11 +20,8 @@
#include "base/allocator/partition_allocator/starscan/starscan_fwd.h"
#include "base/allocator/partition_allocator/starscan/write_protector.h"
-// TODO(crbug.com/1288247): Remove this when migration is complete.
namespace partition_alloc::internal {
-class StarScanSnapshot;
-
class PCScanTask;
// Internal PCScan singleton. The separation between frontend and backend is
@@ -111,7 +108,7 @@
private:
friend internal::base::NoDestructor<PCScanInternal>;
- friend class partition_alloc::internal::StarScanSnapshot;
+ friend class StarScanSnapshot;
using StackTops = std::unordered_map<
internal::base::PlatformThreadId,
@@ -149,11 +146,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove this when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::PCScanInternal;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_PCSCAN_INTERNAL_H_
diff --git a/allocator/partition_allocator/starscan/pcscan_scheduling.cc b/allocator/partition_allocator/starscan/pcscan_scheduling.cc
index 99a4337..007408c 100644
--- a/allocator/partition_allocator/starscan/pcscan_scheduling.cc
+++ b/allocator/partition_allocator/starscan/pcscan_scheduling.cc
@@ -33,8 +33,7 @@
scheduling_enabled_.store(true, std::memory_order_relaxed);
// Check if *Scan needs to be run immediately.
if (NeedsToImmediatelyScan())
- ::base::internal::PCScan::PerformScan(
- ::base::internal::PCScan::InvocationMode::kNonBlocking);
+ PCScan::PerformScan(PCScan::InvocationMode::kNonBlocking);
}
size_t PCScanSchedulingBackend::ScanStarted() {
diff --git a/allocator/partition_allocator/starscan/pcscan_scheduling.h b/allocator/partition_allocator/starscan/pcscan_scheduling.h
index b0b259c..6b50048 100644
--- a/allocator/partition_allocator/starscan/pcscan_scheduling.h
+++ b/allocator/partition_allocator/starscan/pcscan_scheduling.h
@@ -198,14 +198,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove these when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::LimitBackend;
-using ::partition_alloc::internal::MUAwareTaskBasedBackend;
-using ::partition_alloc::internal::PCScanScheduler;
-using ::partition_alloc::internal::QuarantineData;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_PCSCAN_SCHEDULING_H_
diff --git a/allocator/partition_allocator/starscan/raceful_worklist.h b/allocator/partition_allocator/starscan/raceful_worklist.h
index 1fee777..b05e38e 100644
--- a/allocator/partition_allocator/starscan/raceful_worklist.h
+++ b/allocator/partition_allocator/starscan/raceful_worklist.h
@@ -139,9 +139,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove these when migration is complete.
-namespace base::internal {
-using ::partition_alloc::internal::RacefulWorklist;
-}
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_RACEFUL_WORKLIST_H_
diff --git a/allocator/partition_allocator/starscan/scan_loop.h b/allocator/partition_allocator/starscan/scan_loop.h
index 1e03e71..b9c0bd2 100644
--- a/allocator/partition_allocator/starscan/scan_loop.h
+++ b/allocator/partition_allocator/starscan/scan_loop.h
@@ -224,11 +224,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove this when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::ScanLoop;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_SCAN_LOOP_H_
diff --git a/allocator/partition_allocator/starscan/snapshot.h b/allocator/partition_allocator/starscan/snapshot.h
index 8828896..3486932 100644
--- a/allocator/partition_allocator/starscan/snapshot.h
+++ b/allocator/partition_allocator/starscan/snapshot.h
@@ -91,11 +91,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove this when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::StarScanSnapshot;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_SNAPSHOT_H_
diff --git a/allocator/partition_allocator/starscan/stack/stack.h b/allocator/partition_allocator/starscan/stack/stack.h
index 89fe5cc..dfca8f4 100644
--- a/allocator/partition_allocator/starscan/stack/stack.h
+++ b/allocator/partition_allocator/starscan/stack/stack.h
@@ -45,14 +45,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove these when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::GetStackPointer;
-using ::partition_alloc::internal::GetStackTop;
-using ::partition_alloc::internal::Stack;
-using ::partition_alloc::internal::StackVisitor;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_STACK_STACK_H_
diff --git a/allocator/partition_allocator/starscan/starscan_fwd.h b/allocator/partition_allocator/starscan/starscan_fwd.h
index ba7fc33..a1ac5d2 100644
--- a/allocator/partition_allocator/starscan/starscan_fwd.h
+++ b/allocator/partition_allocator/starscan/starscan_fwd.h
@@ -27,12 +27,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove these when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::Context;
-using ::partition_alloc::internal::SimdSupport;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_STARSCAN_FWD_H_
diff --git a/allocator/partition_allocator/starscan/stats_collector.h b/allocator/partition_allocator/starscan/stats_collector.h
index 7df4cea..c6f21ec 100644
--- a/allocator/partition_allocator/starscan/stats_collector.h
+++ b/allocator/partition_allocator/starscan/stats_collector.h
@@ -245,11 +245,4 @@
} // namespace internal
} // namespace partition_alloc
-// TODO(crbug.com/1151236): Remove this when migration is complete.
-namespace base::internal {
-
-using ::partition_alloc::internal::StatsCollector;
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_STATS_COLLECTOR_H_
diff --git a/allocator/partition_allocator/starscan/write_protector.cc b/allocator/partition_allocator/starscan/write_protector.cc
index 80daabe..51660fb 100644
--- a/allocator/partition_allocator/starscan/write_protector.cc
+++ b/allocator/partition_allocator/starscan/write_protector.cc
@@ -27,9 +27,8 @@
namespace partition_alloc::internal {
-::base::internal::PCScan::ClearType NoWriteProtector::SupportedClearType()
- const {
- return ::base::internal::PCScan::ClearType::kLazy;
+PCScan::ClearType NoWriteProtector::SupportedClearType() const {
+ return PCScan::ClearType::kLazy;
}
#if defined(PA_STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED)
@@ -58,7 +57,7 @@
// Enter the safepoint. Concurrent faulted writes will wait until safepoint
// finishes.
- ::base::internal::PCScan::JoinScanIfNeeded();
+ PCScan::JoinScanIfNeeded();
}
}
} // namespace
@@ -121,10 +120,8 @@
UserFaultFDWPSet(uffd_, begin, length, UserFaultFDWPMode::kUnprotect);
}
-::base::internal::PCScan::ClearType
-UserFaultFDWriteProtector::SupportedClearType() const {
- return IsSupported() ? ::base::internal::PCScan::ClearType::kEager
- : ::base::internal::PCScan::ClearType::kLazy;
+PCScan::ClearType UserFaultFDWriteProtector::SupportedClearType() const {
+ return IsSupported() ? PCScan::ClearType::kEager : PCScan::ClearType::kLazy;
}
bool UserFaultFDWriteProtector::IsSupported() const {
diff --git a/allocator/partition_allocator/starscan/write_protector.h b/allocator/partition_allocator/starscan/write_protector.h
index e7cfae6..c5d4eaa 100644
--- a/allocator/partition_allocator/starscan/write_protector.h
+++ b/allocator/partition_allocator/starscan/write_protector.h
@@ -28,14 +28,14 @@
virtual bool IsEnabled() const = 0;
- virtual ::base::internal::PCScan::ClearType SupportedClearType() const = 0;
+ virtual PCScan::ClearType SupportedClearType() const = 0;
};
class NoWriteProtector final : public WriteProtector {
public:
void ProtectPages(uintptr_t, size_t) final {}
void UnprotectPages(uintptr_t, size_t) final {}
- ::base::internal::PCScan::ClearType SupportedClearType() const final;
+ PCScan::ClearType SupportedClearType() const final;
inline bool IsEnabled() const override;
};
@@ -55,7 +55,7 @@
void ProtectPages(uintptr_t, size_t) final;
void UnprotectPages(uintptr_t, size_t) final;
- ::base::internal::PCScan::ClearType SupportedClearType() const final;
+ PCScan::ClearType SupportedClearType() const final;
inline bool IsEnabled() const override;
@@ -73,15 +73,4 @@
} // namespace partition_alloc::internal
-// TODO(crbug.com/1288247): Remove these when migration is complete.
-namespace base::internal {
-using ::partition_alloc::internal::NoWriteProtector;
-using ::partition_alloc::internal::WriteProtector;
-
-#if defined(PA_STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED)
-using ::partition_alloc::internal::UserFaultFDWriteProtector;
-#endif // defined(PA_STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED)
-
-} // namespace base::internal
-
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_STARSCAN_WRITE_PROTECTOR_H_
diff --git a/memory/nonscannable_memory.cc b/memory/nonscannable_memory.cc
index 4ed8f6a..1eea80d 100644
--- a/memory/nonscannable_memory.cc
+++ b/memory/nonscannable_memory.cc
@@ -53,7 +53,8 @@
template <bool Quarantinable>
void NonScannableAllocatorImpl<Quarantinable>::NotifyPCScanEnabled() {
- allocator_.reset(MakePCScanMetadata<partition_alloc::PartitionAllocator>());
+ allocator_.reset(partition_alloc::internal::MakePCScanMetadata<
+ partition_alloc::PartitionAllocator>());
allocator_->init({
partition_alloc::PartitionOptions::AlignedAlloc::kDisallowed,
partition_alloc::PartitionOptions::ThreadCache::kDisabled,
@@ -66,7 +67,8 @@
partition_alloc::PartitionOptions::UseConfigurablePool::kNo,
});
if (Quarantinable)
- PCScan::RegisterNonScannableRoot(allocator_->root());
+ partition_alloc::internal::PCScan::RegisterNonScannableRoot(
+ allocator_->root());
pcscan_enabled_.store(true, std::memory_order_release);
}
diff --git a/memory/nonscannable_memory.h b/memory/nonscannable_memory.h
index 4c51079..af4ae44 100644
--- a/memory/nonscannable_memory.h
+++ b/memory/nonscannable_memory.h
@@ -59,7 +59,8 @@
NonScannableAllocatorImpl();
~NonScannableAllocatorImpl();
- std::unique_ptr<partition_alloc::PartitionAllocator, PCScanMetadataDeleter>
+ std::unique_ptr<partition_alloc::PartitionAllocator,
+ partition_alloc::internal::PCScanMetadataDeleter>
allocator_;
std::atomic_bool pcscan_enabled_{false};
};
diff --git a/threading/platform_thread_posix.cc b/threading/platform_thread_posix.cc
index fb5df2e..6b68ba3 100644
--- a/threading/platform_thread_posix.cc
+++ b/threading/platform_thread_posix.cc
@@ -78,7 +78,8 @@
#if !BUILDFLAG(IS_NACL)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- internal::PCScan::NotifyThreadCreated(internal::GetStackPointer());
+ partition_alloc::internal::PCScan::NotifyThreadCreated(
+ partition_alloc::internal::GetStackPointer());
#endif
#if BUILDFLAG(IS_APPLE)
@@ -104,7 +105,7 @@
PlatformThread::CurrentId());
#if !BUILDFLAG(IS_NACL) && BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- internal::PCScan::NotifyThreadDestroyed();
+ partition_alloc::internal::PCScan::NotifyThreadDestroyed();
#endif
base::TerminateOnThread();
diff --git a/threading/platform_thread_win.cc b/threading/platform_thread_win.cc
index 5d01f88..cdb8135 100644
--- a/threading/platform_thread_win.cc
+++ b/threading/platform_thread_win.cc
@@ -114,7 +114,8 @@
DUPLICATE_SAME_ACCESS);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- internal::PCScan::NotifyThreadCreated(internal::GetStackPointer());
+ partition_alloc::internal::PCScan::NotifyThreadCreated(
+ partition_alloc::internal::GetStackPointer());
#endif
win::ScopedHandle scoped_platform_handle;
@@ -134,7 +135,7 @@
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
- internal::PCScan::NotifyThreadDestroyed();
+ partition_alloc::internal::PCScan::NotifyThreadDestroyed();
#endif
// Ensure thread priority is at least NORMAL before initiating thread