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

Unified Diff: pdf/pdf.cc

Issue 1346143003: Don't initialize V8 via Blink in ppapi plugins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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/OWNERS ('k') | pdf/pdf.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdf.cc
diff --git a/pdf/pdf.cc b/pdf/pdf.cc
index 655a13359eefb7420310213430ceed8ab4713730..3a088a5e410fe9cc22a4cef7a089af152289a6ed 100644
--- a/pdf/pdf.cc
+++ b/pdf/pdf.cc
@@ -10,6 +10,8 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "gin/array_buffer.h"
+#include "gin/public/isolate_holder.h"
#include "pdf/out_of_process_instance.h"
#include "ppapi/c/ppp.h"
#include "ppapi/cpp/private/internal_module.h"
@@ -18,6 +20,8 @@
bool g_sdk_initialized_via_pepper = false;
+gin::IsolateHolder* g_isolate_holder = nullptr;
+
namespace chrome_pdf {
PDFModule::PDFModule() {
@@ -26,6 +30,11 @@ PDFModule::PDFModule() {
PDFModule::~PDFModule() {
if (g_sdk_initialized_via_pepper) {
chrome_pdf::ShutdownSDK();
+ if (g_sdk_initialized_via_pepper) {
Lei Zhang 2015/09/16 21:22:24 Didn't we just check |g_sdk_initialized_via_pepper
jochen (gone - plz use gerrit) 2015/09/17 06:55:07 done
+ g_isolate_holder->isolate()->Exit();
+ delete g_isolate_holder;
+ g_isolate_holder = nullptr;
+ }
g_sdk_initialized_via_pepper = false;
}
}
@@ -45,8 +54,17 @@ pp::Instance* PDFModule::CreateInstance(PP_Instance instance) {
v8::V8::SetNativesDataBlob(&natives);
v8::V8::SetSnapshotDataBlob(&snapshot);
}
- if (!chrome_pdf::InitializeSDK())
+ gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
+ gin::ArrayBufferAllocator::SharedInstance());
+ g_isolate_holder =
Lei Zhang 2015/09/16 21:22:24 CreateInstance() only gets called once per process
raymes 2015/09/17 02:30:41 I believe CreateInstance will get called multiple
jochen (gone - plz use gerrit) 2015/09/17 06:55:07 this block is protected by !g_sdk_initialized_via_
+ new gin::IsolateHolder(gin::IsolateHolder::kSingleThread);
+ g_isolate_holder->isolate()->Enter();
raymes 2015/09/17 02:30:41 nit: indentation looks funny here.
jochen (gone - plz use gerrit) 2015/09/17 06:55:07 done
+ if (!chrome_pdf::InitializeSDK()) {
+ g_isolate_holder->isolate()->Exit();
Lei Zhang 2015/09/16 21:22:24 Write a function for these 3 lines? Then reused on
jochen (gone - plz use gerrit) 2015/09/17 06:55:07 done
+ delete g_isolate_holder;
+ g_isolate_holder = nullptr;
return NULL;
+ }
g_sdk_initialized_via_pepper = true;
}
« no previous file with comments | « pdf/OWNERS ('k') | pdf/pdf.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698