xref: /aosp_15_r20/external/pdfium/testing/fuzzers/xfa_process_state.cc (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2020 The PDFium 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 "testing/fuzzers/xfa_process_state.h"
6 
7 #include "fxjs/gc/heap.h"
8 #include "v8/include/libplatform/libplatform.h"
9 
XFAProcessState(v8::Platform * platform,v8::Isolate * isolate)10 XFAProcessState::XFAProcessState(v8::Platform* platform, v8::Isolate* isolate)
11     : platform_(platform), isolate_(isolate), heap_(FXGC_CreateHeap()) {}
12 
~XFAProcessState()13 XFAProcessState::~XFAProcessState() {
14   FXGC_ForceGarbageCollection(heap_.get());
15 }
16 
GetHeap() const17 cppgc::Heap* XFAProcessState::GetHeap() const {
18   return heap_.get();
19 }
20 
ForceGCAndPump()21 void XFAProcessState::ForceGCAndPump() {
22   FXGC_ForceGarbageCollection(heap_.get());
23   while (v8::platform::PumpMessageLoop(platform_, isolate_))
24     continue;
25 }
26