0

Always create a PDFEngine in OutOfProcessInstance::Init()

Revival of crrev.com/c/1931439 by tsepez@.

Init() is only called on newly created instances, so there's no way for
|engine_| to be created before Init() is called. Instead of
conditionalizing the creation of |engine_|, assert that it hasn't been
created yet.

Bug: 852273
Change-Id: Id919a9fc9bcf23ee8d66e81fbfd745c164da87cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207740
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773493}
This commit is contained in:
Daniel Hosseinian
2020-05-30 06:35:21 +00:00
committed by Commit Bot
parent a5d219ef07
commit 1d73086cbe

@ -455,6 +455,8 @@ OutOfProcessInstance::~OutOfProcessInstance() {
bool OutOfProcessInstance::Init(uint32_t argc,
const char* argn[],
const char* argv[]) {
DCHECK(!engine_);
pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this);
if (!document_url_var.is_string())
return false;
@ -518,9 +520,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
if (!stream_url)
stream_url = original_url;
if (!engine_) {
engine_ = PDFEngine::Create(this, enable_javascript);
}
engine_ = PDFEngine::Create(this, enable_javascript);
// If we're in print preview mode we don't need to load the document yet.
// A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting