From 3355f459ecd2207c0cd1719c2cdafa15eea87bf6 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 5 Feb 2018 21:13:35 +0000 Subject: Fix testing.cpp build with v8_use_external_startup_data=false. Also change the InitializeV8ForPDFium() for use with startup data to InitializeV8ForPDFiumWithStartupData(). Change-Id: I594c2bf9470b6549195b7361bb7fcb45def50c61 Reviewed-on: https://pdfium-review.googlesource.com/25371 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- samples/pdfium_test.cc | 4 ++-- testing/embedder_test_main.cpp | 8 ++++---- testing/test_support.cpp | 15 ++++++--------- testing/test_support.h | 5 ++++- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 37e36d322d..707fbb1028 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -1568,8 +1568,8 @@ int main(int argc, const char* argv[]) { #ifdef V8_USE_EXTERNAL_STARTUP_DATA v8::StartupData natives; v8::StartupData snapshot; - platform = InitializeV8ForPDFium(options.exe_path, options.bin_directory, - &natives, &snapshot); + platform = InitializeV8ForPDFiumWithStartupData( + options.exe_path, options.bin_directory, &natives, &snapshot); #else // V8_USE_EXTERNAL_STARTUP_DATA platform = InitializeV8ForPDFium(options.exe_path); #endif // V8_USE_EXTERNAL_STARTUP_DATA diff --git a/testing/embedder_test_main.cpp b/testing/embedder_test_main.cpp index 03c192b08a..0c3ceb60ce 100644 --- a/testing/embedder_test_main.cpp +++ b/testing/embedder_test_main.cpp @@ -34,13 +34,13 @@ class Environment : public testing::Environment { #ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA if (g_v8_natives && g_v8_snapshot) { - platform_ = - InitializeV8ForPDFium(g_exe_path, std::string(), nullptr, nullptr); + platform_ = InitializeV8ForPDFiumWithStartupData( + g_exe_path, std::string(), nullptr, nullptr); } else { g_v8_natives = new v8::StartupData; g_v8_snapshot = new v8::StartupData; - platform_ = InitializeV8ForPDFium(g_exe_path, std::string(), g_v8_natives, - g_v8_snapshot); + platform_ = InitializeV8ForPDFiumWithStartupData( + g_exe_path, std::string(), g_v8_natives, g_v8_snapshot); } #else platform_ = InitializeV8ForPDFium(g_exe_path); diff --git a/testing/test_support.cpp b/testing/test_support.cpp index f682451c27..2b6f436c32 100644 --- a/testing/test_support.cpp +++ b/testing/test_support.cpp @@ -60,8 +60,8 @@ bool GetExternalData(const std::string& exe_path, } #endif // V8_USE_EXTERNAL_STARTUP_DATA -std::unique_ptr InitializeV8Common(const char* exe_path) { - v8::V8::InitializeICUDefaultLocation(exe_path); +std::unique_ptr InitializeV8Common(const std::string& exe_path) { + v8::V8::InitializeICUDefaultLocation(exe_path.c_str()); std::unique_ptr platform = v8::platform::NewDefaultPlatform(); v8::V8::InitializePlatform(platform.get()); @@ -178,12 +178,12 @@ std::string GenerateMD5Base16(const uint8_t* data, uint32_t size) { #ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA -std::unique_ptr InitializeV8ForPDFium( +std::unique_ptr InitializeV8ForPDFiumWithStartupData( const std::string& exe_path, const std::string& bin_dir, v8::StartupData* natives_blob, v8::StartupData* snapshot_blob) { - std::unique_ptr platform = InitializeV8Common(exe_path.c_str()); + std::unique_ptr platform = InitializeV8Common(exe_path); if (natives_blob && snapshot_blob) { if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob)) return nullptr; @@ -196,11 +196,8 @@ std::unique_ptr InitializeV8ForPDFium( } #else // V8_USE_EXTERNAL_STARTUP_DATA std::unique_ptr InitializeV8ForPDFium( - const std::string& exe_path, - std::unique_ptr* platform) { - std::unique_ptr platform = - InitializeV8Common(exe_path.c_str(), platform); - return platform; + const std::string& exe_path) { + return InitializeV8Common(exe_path); } #endif // V8_USE_EXTERNAL_STARTUP_DATA #endif // PDF_ENABLE_V8 diff --git a/testing/test_support.h b/testing/test_support.h index 1b7692c3ed..f26e161544 100644 --- a/testing/test_support.h +++ b/testing/test_support.h @@ -91,7 +91,10 @@ class Platform; namespace v8 { class StartupData; } -std::unique_ptr InitializeV8ForPDFium( + +// |natives_blob| and |snapshot_blob| are optional out parameters. They should +// either both be valid or both be nullptrs. +std::unique_ptr InitializeV8ForPDFiumWithStartupData( const std::string& exe_path, const std::string& bin_dir, v8::StartupData* natives_blob, -- cgit v1.2.3