xref: /aosp_15_r20/external/pdfium/testing/fuzzers/pdf_fuzzer_init_public.h (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 #ifndef TESTING_FUZZERS_PDF_FUZZER_INIT_PUBLIC_H_
6 #define TESTING_FUZZERS_PDF_FUZZER_INIT_PUBLIC_H_
7 
8 #include <memory>
9 
10 #include "public/fpdf_ext.h"
11 #include "public/fpdfview.h"
12 
13 #ifdef PDF_ENABLE_V8
14 #include "fxjs/cfx_v8.h"
15 #include "v8/include/v8-array-buffer.h"
16 #include "v8/include/v8-snapshot.h"
17 #endif  // PDF_ENABLE_V8
18 
19 class XFAProcessState;
20 
21 #ifdef PDF_ENABLE_V8
22 namespace v8 {
23 class Isolate;
24 class Platform;
25 }  // namespace v8
26 #endif  // PDF_ENABLE_V8
27 
28 // Initializes the library once for all runs of the fuzzer.
29 class PDFFuzzerInitPublic {
30  public:
31   PDFFuzzerInitPublic();
32   ~PDFFuzzerInitPublic();
33 
34  private:
35   FPDF_LIBRARY_CONFIG config_;
36   UNSUPPORT_INFO unsupport_info_;
37 #ifdef PDF_ENABLE_V8
38 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
39   v8::StartupData snapshot_blob_;
40 #endif  // V8_USE_EXTERNAL_STARTUP_DATA
41   std::unique_ptr<v8::Platform> platform_;
42   std::unique_ptr<v8::ArrayBuffer::Allocator> allocator_;
43   std::unique_ptr<v8::Isolate, CFX_V8IsolateDeleter> isolate_;
44 #ifdef PDF_ENABLE_XFA
45   std::unique_ptr<XFAProcessState> xfa_process_state_;
46 #endif  // PDF_ENABLE_XFA
47 #endif  // PDF_ENABLE_V8
48 };
49 
50 #endif  // TESTING_FUZZERS_PDF_FUZZER_INIT_PUBLIC_H_
51