Skip to content

Commit

Permalink
Don't initialize V8 via Blink in ppapi plugins
Browse files Browse the repository at this point in the history
Instead, for the PDF plugin, use gin to manage V8.

Also add myself as owner for the v8 stuff.

BUG=530093
R=raymes@chromium.org,thestig@chromium.org

Review URL: https://codereview.chromium.org/1346143003

Cr-Commit-Position: refs/heads/master@{#349379}
  • Loading branch information
jeisinger authored and Commit bot committed Sep 17, 2015
1 parent 7f80ba1 commit 7f15aa5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions content/ppapi_plugin/ppapi_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker)
command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs));

blink_platform_impl_.reset(new PpapiBlinkPlatformImpl);
blink::initialize(blink_platform_impl_.get());
blink::initializeWithoutV8(blink_platform_impl_.get());

if (!is_broker_) {
scoped_refptr<ppapi::proxy::PluginMessageFilter> plugin_filter(
Expand Down Expand Up @@ -141,7 +141,7 @@ void PpapiThread::Shutdown() {
if (plugin_entry_points_.shutdown_module)
plugin_entry_points_.shutdown_module();
blink_platform_impl_->Shutdown();
blink::shutdown();
blink::shutdownWithoutV8();
}

bool PpapiThread::Send(IPC::Message* msg) {
Expand Down
1 change: 1 addition & 0 deletions pdf/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static_library("pdf") {
"//base",
"//components/ui/zoom",
"//content/public/common",
"//gin",
"//net",
"//ppapi/cpp:objects",
"//ppapi/cpp/private:internal_module",
Expand Down
2 changes: 1 addition & 1 deletion pdf/DEPS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include_rules = [
"+chrome/common/content_restriction.h",
"+gin/public/gin_embedders.h",
"+gin",
"+net",
"+ppapi",
"+printing/units.h",
Expand Down
1 change: 1 addition & 0 deletions pdf/OWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
gene@chromium.org
jam@chromium.org
jochen@chromium.org
raymes@chromium.org
thestig@chromium.org
26 changes: 24 additions & 2 deletions pdf/pdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,36 @@

#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"
#include "ppapi/cpp/private/pdf.h"
#include "v8/include/v8.h"

namespace chrome_pdf {

namespace {

bool g_sdk_initialized_via_pepper = false;

namespace chrome_pdf {
gin::IsolateHolder* g_isolate_holder = nullptr;

void TearDownV8() {
g_isolate_holder->isolate()->Exit();
delete g_isolate_holder;
g_isolate_holder = nullptr;
}

} // namespace

PDFModule::PDFModule() {
}

PDFModule::~PDFModule() {
if (g_sdk_initialized_via_pepper) {
TearDownV8();
chrome_pdf::ShutdownSDK();
g_sdk_initialized_via_pepper = false;
}
Expand All @@ -45,8 +60,15 @@ 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 =
new gin::IsolateHolder(gin::IsolateHolder::kSingleThread);
g_isolate_holder->isolate()->Enter();
if (!chrome_pdf::InitializeSDK()) {
TearDownV8();
return NULL;
}
g_sdk_initialized_via_pepper = true;
}

Expand Down
1 change: 1 addition & 0 deletions pdf/pdf.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'../base/base.gyp:base',
'../components/components.gyp:ui_zoom',
'../content/content.gyp:content_common',
'../gin/gin.gyp:gin',
'../net/net.gyp:net',
'../ppapi/ppapi.gyp:ppapi_cpp_objects',
'../ppapi/ppapi.gyp:ppapi_internal_module',
Expand Down

0 comments on commit 7f15aa5

Please sign in to comment.