mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +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
74 lines
1.6 KiB
C++
74 lines
1.6 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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 "PDFiumParent.h"
|
|
#include "nsDeviceContextSpecWin.h"
|
|
#include "mozilla/gfx/PrintTargetEMF.h"
|
|
|
|
namespace mozilla {
|
|
namespace widget {
|
|
|
|
PDFiumParent::PDFiumParent(PrintTargetEMF* aTarget)
|
|
: mTarget(aTarget)
|
|
{
|
|
}
|
|
|
|
bool
|
|
PDFiumParent::Init(IPC::Channel* aChannel, base::ProcessId aPid)
|
|
{
|
|
if (NS_WARN_IF(!Open(aChannel, aPid))) {
|
|
return false;
|
|
}
|
|
|
|
AddRef();
|
|
return true;
|
|
}
|
|
|
|
void
|
|
PDFiumParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
{
|
|
// mTarget is not nullptr, which means the print job is not done
|
|
// (EndConversion is not called yet). The IPC channel is broken for some
|
|
// reasons. We should tell mTarget to abort this print job.
|
|
if (mTarget) {
|
|
mTarget->ChannelIsBroken();
|
|
}
|
|
}
|
|
|
|
mozilla::ipc::IPCResult
|
|
PDFiumParent::RecvConvertToEMFDone(const nsresult& aResult,
|
|
mozilla::ipc::Shmem&& aEMFContents)
|
|
{
|
|
MOZ_ASSERT(aEMFContents.IsReadable());
|
|
|
|
if (mTarget) {
|
|
mTarget->ConvertToEMFDone(aResult, Move(aEMFContents));
|
|
}
|
|
|
|
return IPC_OK();
|
|
}
|
|
|
|
void PDFiumParent::EndConversion()
|
|
{
|
|
// The printing job is done(all pages printed, or print job cancel, or print
|
|
// job abort), reset mTarget since it may not valid afterward.
|
|
mTarget = nullptr;
|
|
}
|
|
|
|
void
|
|
PDFiumParent::OnChannelConnected(int32_t pid)
|
|
{
|
|
SetOtherProcessId(pid);
|
|
}
|
|
|
|
void
|
|
PDFiumParent::DeallocPPDFiumParent()
|
|
{
|
|
Release();
|
|
}
|
|
|
|
} // namespace widget
|
|
} // namespace mozilla
|