Bug 1399787 - Part 14. Prevent RemotePrintJobChild using ipc calls after the channel was destroyed. r=jwatt

If in the future nsDeviceContextSpecWin::BeginDocument was to return
NS_ERROR_FAILURE, then the channel between RemotePrintJobParent and
RemotePrintJobChild will be close at [1]. RemotePrintJobChild keep using ipc
calls after the channel is broken and hits assertions.

PS:
We always hits this assertion by forcing nsDeviceContextSpecWin::BeginDocument
returning NS_ERROR_FAILURE. It's not relative to the change we made in
previous patches.

[1]
https://hg.mozilla.org/mozilla-central/file/b186fddce27f/layout/printing/ipc/RemotePrintJobParent.cpp#l44
MozReview-Commit-ID: 79mZBf301nb

--HG--
extra : rebase_source : 58076a18be56d7eea37ea2f5a147db0048e3493f
extra : intermediate-source : 88df2caad42694dd77f2a518ea8d460d6c88b8c6
extra : source : b920088860904c5d28f3dd2f6eda790dc09be003
This commit is contained in:
cku 2017-10-23 15:57:18 +08:00
Родитель 2716e0d75b
Коммит 1d858e08d2
2 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -71,7 +71,9 @@ RemotePrintJobChild::ProcessPage()
MOZ_ASSERT(mPagePrintTimer);
mPagePrintTimer->WaitForRemotePrint();
Unused << SendProcessPage();
if (!mDestroyed) {
Unused << SendProcessPage();
}
}
mozilla::ipc::IPCResult
@ -116,7 +118,10 @@ RemotePrintJobChild::OnStateChange(nsIWebProgress* aProgress,
nsIRequest* aRequest, uint32_t aStateFlags,
nsresult aStatus)
{
Unused << SendStateChange(aStateFlags, aStatus);
if (!mDestroyed) {
Unused << SendStateChange(aStateFlags, aStatus);
}
return NS_OK;
}
@ -128,8 +133,11 @@ RemotePrintJobChild::OnProgressChange(nsIWebProgress * aProgress,
int32_t aCurTotalProgress,
int32_t aMaxTotalProgress)
{
Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
if (!mDestroyed) {
Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
return NS_OK;
}
@ -146,7 +154,10 @@ RemotePrintJobChild::OnStatusChange(nsIWebProgress* aProgress,
nsIRequest* aRequest, nsresult aStatus,
const char16_t* aMessage)
{
Unused << SendStatusChange(aStatus);
if (!mDestroyed) {
Unused << SendStatusChange(aStatus);
}
return NS_OK;
}
@ -168,6 +179,8 @@ RemotePrintJobChild::ActorDestroy(ActorDestroyReason aWhy)
{
mPagePrintTimer = nullptr;
mPrintEngine = nullptr;
mDestroyed = true;
}
} // namespace layout

Просмотреть файл

@ -55,6 +55,7 @@ private:
void SetNextPageFD(const mozilla::ipc::FileDescriptor& aFd);
bool mPrintInitialized = false;
bool mDestroyed = false;
nsresult mInitializationResult = NS_OK;
RefPtr<nsPagePrintTimer> mPagePrintTimer;
RefPtr<nsPrintEngine> mPrintEngine;