mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
5a90745685
We call PDFiumParent::Close twice under certain conditions. Once in PDFiumProcessParent::Delete, and once in PDFiumProcessParent's dtor. So we may hit MOZ_ABORT which tell us that we are trying to close a closed channel. This patch prevents hitting this abort by: 1. Only close the channel in PDFiumProcessParent::Delete, remove another call in PDFiumProcessParent's dtor. (Please see the change in PDFiumProcessParent.cpp). 2. Remove PDFiumParent::AbortConversion and relative code. We can just use PDFiumParent::EndConversion instead. When calling PDFiumParent::Close, we actually close the IPC channel *synchronously*, which means there is no need to register a callback by PDFiumParent::AbortConversion to receive actor-destroy callback. MozReview-Commit-ID: 9i5j6t54J3h --HG-- extra : rebase_source : 5f74ebc1ecc29e9983c30ca2dd63e0b49bd24a50
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
* vim: sw=2 ts=2 et :
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "PDFiumProcessParent.h"
|
|
#include "nsIRunnable.h"
|
|
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
|
#include "WinUtils.h"
|
|
#endif
|
|
#include "nsDeviceContextSpecWin.h"
|
|
#include "PDFiumParent.h"
|
|
|
|
using mozilla::ipc::GeckoChildProcessHost;
|
|
|
|
namespace mozilla {
|
|
namespace widget {
|
|
|
|
PDFiumProcessParent::PDFiumProcessParent()
|
|
: GeckoChildProcessHost(GeckoProcessType_PDFium)
|
|
{
|
|
MOZ_COUNT_CTOR(PDFiumProcessParent);
|
|
}
|
|
|
|
PDFiumProcessParent::~PDFiumProcessParent()
|
|
{
|
|
MOZ_COUNT_DTOR(PDFiumProcessParent);
|
|
}
|
|
|
|
bool
|
|
PDFiumProcessParent::Launch(PrintTargetEMF* aTarget)
|
|
{
|
|
mLaunchThread = NS_GetCurrentThread();
|
|
|
|
if (!SyncLaunch()) {
|
|
return false;
|
|
}
|
|
|
|
// Open the top level protocol for PDFium process.
|
|
MOZ_ASSERT(!mPDFiumParentActor);
|
|
mPDFiumParentActor = new PDFiumParent(aTarget);
|
|
return mPDFiumParentActor->Init(GetChannel(),
|
|
base::GetProcId(GetChildProcessHandle()));
|
|
}
|
|
|
|
void
|
|
PDFiumProcessParent::Delete()
|
|
{
|
|
// Make sure we do close the IPC channel on the same thread with the one
|
|
// that we create the channel.
|
|
if (!mLaunchThread || mLaunchThread == NS_GetCurrentThread()) {
|
|
if (mPDFiumParentActor) {
|
|
mPDFiumParentActor->EndConversion();
|
|
mPDFiumParentActor->Close();
|
|
}
|
|
|
|
delete this;
|
|
return;
|
|
}
|
|
|
|
mLaunchThread->Dispatch(
|
|
NewNonOwningRunnableMethod("PDFiumProcessParent::Delete", this,
|
|
&PDFiumProcessParent::Delete));
|
|
}
|
|
|
|
} // namespace widget
|
|
} // namespace mozilla
|