summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-07 16:46:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-07 16:46:42 +0000
commitb3a3eaab0471ed4fe22299c02b51b16bec813773 (patch)
treef5df58a232d4f1e65777c67b599c3fa9eaf86636
parent87d02d5cebb13c3925472634d527a1323a36a849 (diff)
downloadpdfium-b3a3eaab0471ed4fe22299c02b51b16bec813773.tar.xz
Revert "[v8-platform] Store the platform in a unique_ptr"
This reverts commit 608e8dd6b87b15772862dca9b7b2e6791a25dab6. Reason for revert: Breaks the roll into Chromium pdf/pdfium/fuzzers/pdfium_fuzzer_helper.cc:238:5: error: no matching function for call to 'InitializeV8ForPDFium' InitializeV8ForPDFium(ProgramPath(), "", &natives_blob, &snapshot_blob, ^~~~~~~~~~~~~~~~~~~~~ ../../third_party/pdfium/testing/test_support.h:94:31: note: candidate function not viable: requires 4 arguments, but 5 were provided std::unique_ptr<v8::Platform> InitializeV8ForPDFium( ^ https://logs.chromium.org/v/?s=chromium%2Fbb%2Ftryserver.chromium.linux%2Flinux_chromium_compile_dbg_ng%2F461077%2F%2B%2Frecipes%2Fsteps%2Fcompile__with_patch_%2F0%2Fstdout Original change's description: > [v8-platform] Store the platform in a unique_ptr > > We want to change the signature of {CreateDefaultPlatform} in the V8 > API to return a unique_ptr instead of a raw pointer to indicate that the > caller owns the platform. With this change we prepare pdfium for this > change. > > R=​thestig@chromium.org > > Change-Id: I4a0a466dfc37b28387a91543623a7a481ca8035a > Reviewed-on: https://pdfium-review.googlesource.com/18191 > Commit-Queue: Lei Zhang <thestig@chromium.org> > Reviewed-by: Lei Zhang <thestig@chromium.org> TBR=thestig@chromium.org,ahaas@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I418c97653e8aba93560537f0d41e1aaa238bf3b4 Reviewed-on: https://pdfium-review.googlesource.com/25850 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--samples/pdfium_test.cc9
-rw-r--r--testing/embedder_test_main.cpp13
-rw-r--r--testing/test_support.cpp34
-rw-r--r--testing/test_support.h17
4 files changed, 36 insertions, 37 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index ebc7412055..b83663db69 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -1567,14 +1567,14 @@ int main(int argc, const char* argv[]) {
}
#ifdef PDF_ENABLE_V8
- std::unique_ptr<v8::Platform> platform;
+ v8::Platform* platform;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
v8::StartupData natives;
v8::StartupData snapshot;
- platform = InitializeV8ForPDFiumWithStartupData(
- options.exe_path, options.bin_directory, &natives, &snapshot);
+ InitializeV8ForPDFium(options.exe_path, options.bin_directory, &natives,
+ &snapshot, &platform);
#else // V8_USE_EXTERNAL_STARTUP_DATA
- platform = InitializeV8ForPDFium(options.exe_path);
+ InitializeV8ForPDFium(options.exe_path, &platform);
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // PDF_ENABLE_V8
@@ -1641,6 +1641,7 @@ int main(int argc, const char* argv[]) {
FPDF_DestroyLibrary();
#ifdef PDF_ENABLE_V8
v8::V8::ShutdownPlatform();
+ delete platform;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
free(const_cast<char*>(natives.data));
diff --git a/testing/embedder_test_main.cpp b/testing/embedder_test_main.cpp
index 0c3ceb60ce..ade6118e64 100644
--- a/testing/embedder_test_main.cpp
+++ b/testing/embedder_test_main.cpp
@@ -34,16 +34,16 @@ class Environment : public testing::Environment {
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
if (g_v8_natives && g_v8_snapshot) {
- platform_ = InitializeV8ForPDFiumWithStartupData(
- g_exe_path, std::string(), nullptr, nullptr);
+ InitializeV8ForPDFium(g_exe_path, std::string(), nullptr, nullptr,
+ &platform_);
} else {
g_v8_natives = new v8::StartupData;
g_v8_snapshot = new v8::StartupData;
- platform_ = InitializeV8ForPDFiumWithStartupData(
- g_exe_path, std::string(), g_v8_natives, g_v8_snapshot);
+ InitializeV8ForPDFium(g_exe_path, std::string(), g_v8_natives,
+ g_v8_snapshot, &platform_);
}
#else
- platform_ = InitializeV8ForPDFium(g_exe_path);
+ InitializeV8ForPDFium(g_exe_path, &platform_);
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // FPDF_ENABLE_V8
}
@@ -51,12 +51,13 @@ class Environment : public testing::Environment {
void TearDown() override {
#ifdef PDF_ENABLE_V8
v8::V8::ShutdownPlatform();
+ delete platform_;
#endif // PDF_ENABLE_V8
}
private:
#ifdef PDF_ENABLE_V8
- std::unique_ptr<v8::Platform> platform_;
+ v8::Platform* platform_;
#endif // PDF_ENABLE_V8
};
diff --git a/testing/test_support.cpp b/testing/test_support.cpp
index 2b6f436c32..b32ec7de96 100644
--- a/testing/test_support.cpp
+++ b/testing/test_support.cpp
@@ -60,18 +60,17 @@ bool GetExternalData(const std::string& exe_path,
}
#endif // V8_USE_EXTERNAL_STARTUP_DATA
-std::unique_ptr<v8::Platform> InitializeV8Common(const std::string& exe_path) {
- v8::V8::InitializeICUDefaultLocation(exe_path.c_str());
+void InitializeV8Common(const char* exe_path, v8::Platform** platform) {
+ v8::V8::InitializeICUDefaultLocation(exe_path);
- std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
- v8::V8::InitializePlatform(platform.get());
+ *platform = v8::platform::CreateDefaultPlatform();
+ v8::V8::InitializePlatform(*platform);
// By enabling predictable mode, V8 won't post any background tasks.
// By enabling GC, it makes it easier to chase use-after-free.
const char v8_flags[] = "--predictable --expose-gc";
v8::V8::SetFlagsFromString(v8_flags, static_cast<int>(strlen(v8_flags)));
v8::V8::Initialize();
- return platform;
}
#endif // PDF_ENABLE_V8
@@ -178,26 +177,27 @@ std::string GenerateMD5Base16(const uint8_t* data, uint32_t size) {
#ifdef PDF_ENABLE_V8
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
-std::unique_ptr<v8::Platform> InitializeV8ForPDFiumWithStartupData(
- const std::string& exe_path,
- const std::string& bin_dir,
- v8::StartupData* natives_blob,
- v8::StartupData* snapshot_blob) {
- std::unique_ptr<v8::Platform> platform = InitializeV8Common(exe_path);
+bool InitializeV8ForPDFium(const std::string& exe_path,
+ const std::string& bin_dir,
+ v8::StartupData* natives_blob,
+ v8::StartupData* snapshot_blob,
+ v8::Platform** platform) {
+ InitializeV8Common(exe_path.c_str(), platform);
if (natives_blob && snapshot_blob) {
if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob))
- return nullptr;
+ return false;
if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob))
- return nullptr;
+ return false;
v8::V8::SetNativesDataBlob(natives_blob);
v8::V8::SetSnapshotDataBlob(snapshot_blob);
}
- return platform;
+ return true;
}
#else // V8_USE_EXTERNAL_STARTUP_DATA
-std::unique_ptr<v8::Platform> InitializeV8ForPDFium(
- const std::string& exe_path) {
- return InitializeV8Common(exe_path);
+bool InitializeV8ForPDFium(const std::string& exe_path,
+ v8::Platform** platform) {
+ InitializeV8Common(exe_path.c_str(), platform);
+ return true;
}
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // PDF_ENABLE_V8
diff --git a/testing/test_support.h b/testing/test_support.h
index f26e161544..ec4b4aeacb 100644
--- a/testing/test_support.h
+++ b/testing/test_support.h
@@ -91,17 +91,14 @@ class Platform;
namespace v8 {
class StartupData;
}
-
-// |natives_blob| and |snapshot_blob| are optional out parameters. They should
-// either both be valid or both be nullptrs.
-std::unique_ptr<v8::Platform> InitializeV8ForPDFiumWithStartupData(
- const std::string& exe_path,
- const std::string& bin_dir,
- v8::StartupData* natives_blob,
- v8::StartupData* snapshot_blob);
+bool InitializeV8ForPDFium(const std::string& exe_path,
+ const std::string& bin_dir,
+ v8::StartupData* natives_blob,
+ v8::StartupData* snapshot_blob,
+ v8::Platform** platform);
#else // V8_USE_EXTERNAL_STARTUP_DATA
-std::unique_ptr<v8::Platform> InitializeV8ForPDFium(
- const std::string& exe_path);
+bool InitializeV8ForPDFium(const std::string& exe_path,
+ v8::Platform** platform);
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // PDF_ENABLE_V8