Bug 1399787 - Part 11.c. Add assertions to make sure no page-done callback from the PrintTarget after the print job done. r=jwatt

MozReview-Commit-ID: FsDqjpy2wtR

--HG--
extra : rebase_source : 40b66df0674e5a571e647e17957032c6bfedd28e
This commit is contained in:
cku 2017-11-30 11:55:12 +08:00
Родитель 25c71788a4
Коммит f07e4b883f
3 изменённых файлов: 23 добавлений и 0 удалений

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

@ -27,6 +27,7 @@ namespace layout {
RemotePrintJobParent::RemotePrintJobParent(nsIPrintSettings* aPrintSettings)
: mPrintSettings(aPrintSettings)
, mIsDoingPrinting(false)
{
MOZ_COUNT_CTOR(RemotePrintJobParent);
}
@ -92,6 +93,8 @@ RemotePrintJobParent::InitializePrintDevice(const nsString& aDocumentTitle,
mPrintDeviceContext->RegisterPageDoneCallback([this](nsresult aResult) { PageDone(aResult); });
}
mIsDoingPrinting = true;
return NS_OK;
}
@ -151,6 +154,8 @@ RemotePrintJobParent::PrintPage(PRFileDescStream& aRecording)
void
RemotePrintJobParent::PageDone(nsresult aResult)
{
MOZ_ASSERT(mIsDoingPrinting);
if (NS_FAILED(aResult)) {
Unused << SendAbortPrint(aResult);
} else {
@ -181,6 +186,8 @@ RemotePrintJobParent::RecvFinalizePrint()
mPrintDeviceContext->UnregisterPageDoneCallback();
}
mIsDoingPrinting = false;
Unused << Send__delete__(this);
return IPC_OK();
}
@ -193,6 +200,8 @@ RemotePrintJobParent::RecvAbortPrint(const nsresult& aRv)
mPrintDeviceContext->UnregisterPageDoneCallback();
}
mIsDoingPrinting = false;
Unused << Send__delete__(this);
return IPC_OK();
}
@ -265,6 +274,8 @@ RemotePrintJobParent::ActorDestroy(ActorDestroyReason aWhy)
if (mPrintDeviceContext) {
mPrintDeviceContext->UnregisterPageDoneCallback();
}
mIsDoingPrinting = false;
}
} // namespace layout

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

@ -87,6 +87,7 @@ private:
UniquePtr<PrintTranslator> mPrintTranslator;
nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
PRFileDescStream mCurrentPageStream;
bool mIsDoingPrinting;
};
} // namespace layout

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

@ -2869,6 +2869,17 @@ nsPrintEngine::PrintPage(nsPrintObject* aPO,
return donePrinting;
}
void
nsPrintEngine::PageDone(nsresult aResult)
{
MOZ_ASSERT(mIsDoingPrinting);
// mPagePrintTimer might be released during RemotePrintFinished, keep a
// reference here to make sure it lives long enough.
RefPtr<nsPagePrintTimer> timer = mPagePrintTimer;
timer->RemotePrintFinished();
}
//-----------------------------------------------------------------
//-- Done: Printing Methods
//-----------------------------------------------------------------