Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1419793008: Setup and tear down V8 if the PDF module is not managed via pepper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/pdf.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index 863108861822fe3c77b6d5d6bca8785a09e86185..d23c141edffcfd6ff0bd4c4b40f2fcaf7352b5ef 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -18,7 +18,9 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "gin/array_buffer.h"
#include "gin/public/gin_embedders.h"
+#include "gin/public/isolate_holder.h"
#include "pdf/draw_utils.h"
#include "pdf/pdfium/pdfium_api_string_buffer_adapter.h"
#include "pdf/pdfium/pdfium_mem_buffer_file_read.h"
@@ -449,9 +451,27 @@ std::string GetDocumentMetadata(FPDF_DOCUMENT doc, const std::string& key) {
return base::UTF16ToUTF8(value);
}
+gin::IsolateHolder* g_isolate_holder = nullptr;
+
+void SetUpV8() {
+ gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
+ gin::ArrayBufferAllocator::SharedInstance());
+ g_isolate_holder =
+ new gin::IsolateHolder(gin::IsolateHolder::kSingleThread);
+ g_isolate_holder->isolate()->Enter();
+}
+
+void TearDownV8() {
+ g_isolate_holder->isolate()->Exit();
+ delete g_isolate_holder;
+ g_isolate_holder = nullptr;
+}
+
} // namespace
bool InitializeSDK() {
+ SetUpV8();
+
FPDF_LIBRARY_CONFIG config;
config.version = 2;
config.m_pUserFontPaths = nullptr;
@@ -470,6 +490,7 @@ bool InitializeSDK() {
}
void ShutdownSDK() {
+ TearDownV8();
FPDF_DestroyLibrary();
}
« no previous file with comments | « pdf/pdf.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698