Add FXGC_ForceGarbageCollection().

Centralize calls to this for use in subsequent CLs.

Change-Id: I6198a8e1b5c3563f0f69eb2197fa3683a8d58d16
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72234
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/gc/gced_tree_node_unittest.cpp b/fxjs/gc/gced_tree_node_unittest.cpp
index 396493d..4d9f635 100644
--- a/fxjs/gc/gced_tree_node_unittest.cpp
+++ b/fxjs/gc/gced_tree_node_unittest.cpp
@@ -48,9 +48,7 @@
   }
 
   void ForceGCAndPump() {
-    heap()->ForceGarbageCollectionSlow(
-        "GCedTreeNodeUnitTest", "test",
-        cppgc::Heap::StackState::kNoHeapPointers);
+    FXGC_ForceGarbageCollection(heap());
     V8TestEnvironment::PumpPlatformMessageLoop(isolate());
   }
 
diff --git a/fxjs/gc/heap.cpp b/fxjs/gc/heap.cpp
index 3c729c7..404ee10 100644
--- a/fxjs/gc/heap.cpp
+++ b/fxjs/gc/heap.cpp
@@ -69,12 +69,16 @@
   return FXGCScopedHeap(heap.release());
 }
 
+void FXGC_ForceGarbageCollection(cppgc::Heap* heap) {
+  heap->ForceGarbageCollectionSlow("FXGC", "ForceGarbageCollection",
+                                   cppgc::Heap::StackState::kNoHeapPointers);
+}
+
 void FXGCHeapDeleter::operator()(cppgc::Heap* heap) {
   ASSERT(heap);
   ASSERT(g_platform_ref_count > 0);
   --g_platform_ref_count;
 
-  heap->ForceGarbageCollectionSlow("FXGCHeapDeleter", "FinalGCBeforeDelete",
-                                   cppgc::Heap::StackState::kNoHeapPointers);
+  FXGC_ForceGarbageCollection(heap);
   delete heap;
 }
diff --git a/fxjs/gc/heap.h b/fxjs/gc/heap.h
index 35ad4f6..bf60833 100644
--- a/fxjs/gc/heap.h
+++ b/fxjs/gc/heap.h
@@ -20,6 +20,7 @@
 void FXGC_Initialize(v8::Platform* platform);
 void FXGC_Release();
 FXGCScopedHeap FXGC_CreateHeap();
+void FXGC_ForceGarbageCollection(cppgc::Heap* heap);
 
 #define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED \
   template <typename T>                      \
diff --git a/fxjs/gc/heap_unittest.cpp b/fxjs/gc/heap_unittest.cpp
index 685c357..76e0e40 100644
--- a/fxjs/gc/heap_unittest.cpp
+++ b/fxjs/gc/heap_unittest.cpp
@@ -93,8 +93,7 @@
     EXPECT_EQ(1u, PseudoCollectible::LiveCount());
     EXPECT_EQ(0u, PseudoCollectible::DeadCount());
   }
-  heap1->ForceGarbageCollectionSlow("NoReferences", "test",
-                                    cppgc::Heap::StackState::kNoHeapPointers);
+  FXGC_ForceGarbageCollection(heap1.get());
   EXPECT_EQ(0u, PseudoCollectible::LiveCount());
   EXPECT_EQ(1u, PseudoCollectible::DeadCount());
 }
@@ -115,9 +114,7 @@
     EXPECT_EQ(1u, PseudoCollectible::LiveCount());
     EXPECT_EQ(0u, PseudoCollectible::DeadCount());
 
-    heap1->ForceGarbageCollectionSlow("HasReferences", "test",
-                                      cppgc::Heap::StackState::kNoHeapPointers);
-
+    FXGC_ForceGarbageCollection(heap1.get());
     EXPECT_TRUE(PseudoCollectible::s_persistent_->IsLive());
     EXPECT_EQ(1u, PseudoCollectible::LiveCount());
     EXPECT_EQ(0u, PseudoCollectible::DeadCount());