K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2020 The PDFium Authors |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 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 |
Tom Sepez | 945333e | 2020-09-16 18:13:08 +0000 | [diff] [blame] | 14 | #include "fxjs/cfx_v8.h" |
Lei Zhang | bfcf156 | 2022-07-07 01:49:26 +0000 | [diff] [blame] | 15 | #include "v8/include/v8-array-buffer.h" |
| 16 | #include "v8/include/v8-snapshot.h" |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 17 | #endif // PDF_ENABLE_V8 |
| 18 | |
Lei Zhang | 7257a3f | 2020-09-17 22:26:52 +0000 | [diff] [blame] | 19 | class XFAProcessState; |
| 20 | |
Lei Zhang | bfcf156 | 2022-07-07 01:49:26 +0000 | [diff] [blame] | 21 | #ifdef PDF_ENABLE_V8 |
| 22 | namespace v8 { |
| 23 | class Isolate; |
| 24 | class Platform; |
| 25 | } // namespace v8 |
| 26 | #endif // PDF_ENABLE_V8 |
| 27 | |
Lei Zhang | 7257a3f | 2020-09-17 22:26:52 +0000 | [diff] [blame] | 28 | // Initializes the library once for all runs of the fuzzer. |
| 29 | class PDFFuzzerInitPublic { |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 30 | public: |
Lei Zhang | 7257a3f | 2020-09-17 22:26:52 +0000 | [diff] [blame] | 31 | PDFFuzzerInitPublic(); |
| 32 | ~PDFFuzzerInitPublic(); |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | FPDF_LIBRARY_CONFIG config_; |
| 36 | UNSUPPORT_INFO unsupport_info_; |
| 37 | #ifdef PDF_ENABLE_V8 |
Tom Sepez | 54a3b3d | 2021-08-31 18:33:47 +0000 | [diff] [blame] | 38 | #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 39 | v8::StartupData snapshot_blob_; |
Tom Sepez | 54a3b3d | 2021-08-31 18:33:47 +0000 | [diff] [blame] | 40 | #endif // V8_USE_EXTERNAL_STARTUP_DATA |
Tom Sepez | 945333e | 2020-09-16 18:13:08 +0000 | [diff] [blame] | 41 | std::unique_ptr<v8::Platform> platform_; |
| 42 | std::unique_ptr<v8::ArrayBuffer::Allocator> allocator_; |
| 43 | std::unique_ptr<v8::Isolate, CFX_V8IsolateDeleter> isolate_; |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 44 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 7257a3f | 2020-09-17 22:26:52 +0000 | [diff] [blame] | 45 | std::unique_ptr<XFAProcessState> xfa_process_state_; |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 46 | #endif // PDF_ENABLE_XFA |
| 47 | #endif // PDF_ENABLE_V8 |
| 48 | }; |
| 49 | |
Tom Sepez | 0189e53 | 2020-09-15 16:31:43 +0000 | [diff] [blame] | 50 | #endif // TESTING_FUZZERS_PDF_FUZZER_INIT_PUBLIC_H_ |