Balance PerProcessInitializer Acquire()/Release() calls in PDF code.
When PdfViewWebPlugin::InitializeForTesting() gets called, the calls to PerProcessInitializer's Acquire() and Release() methods are out of balance. Fix this by keeping track of whether Acquire() got called or not, and then calling Release() appropriately. Test: pdf_unittests --single-process-tests passes. Change-Id: If494a81b1ce5629be800a4fb903247ecc43e4c1b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3967222 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: K. Moon <kmoon@chromium.org> Cr-Commit-Position: refs/heads/main@{#1061965}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
ae6b6cd04c
commit
08c67a3e8e
@ -331,6 +331,7 @@ bool PdfViewWebPlugin::InitializeCommon() {
|
||||
base::debug::SetCrashKeyString(subresource_url, params->original_url);
|
||||
|
||||
PerProcessInitializer::GetInstance().Acquire();
|
||||
initialized_ = true;
|
||||
|
||||
// Check if the PDF is being loaded in the PDF chrome extension. We only allow
|
||||
// the plugin to be loaded in the extension and print preview to avoid
|
||||
@ -393,15 +394,16 @@ void PdfViewWebPlugin::DidOpen(std::unique_ptr<UrlLoader> loader,
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::Destroy() {
|
||||
if (client_->PluginContainer()) {
|
||||
if (initialized_) {
|
||||
// Explicitly destroy the PDFEngine during destruction as it may call back
|
||||
// into this object.
|
||||
preview_engine_.reset();
|
||||
engine_.reset();
|
||||
PerProcessInitializer::GetInstance().Release();
|
||||
client_->SetPluginContainer(nullptr);
|
||||
}
|
||||
|
||||
client_->SetPluginContainer(nullptr);
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
@ -602,6 +602,8 @@ class PdfViewWebPlugin final : public PDFEngine::Client,
|
||||
// Starts loading accessibility information.
|
||||
void LoadAccessibility();
|
||||
|
||||
bool initialized_ = false;
|
||||
|
||||
blink::WebString selected_text_;
|
||||
|
||||
std::unique_ptr<Client> const client_;
|
||||
|
Reference in New Issue
Block a user