Bug 1156742 Part 11: Allow RemotePrintJobChild to abort the print. r=roc

This is so the RemotePrintJobParent can abort the printing in the child when something goes wrong.
This commit is contained in:
Bob Owen 2015-12-21 20:33:13 +00:00
parent 61d3769790
commit 3641b4f559
3 changed files with 19 additions and 2 deletions

View File

@ -8,6 +8,7 @@
#include "mozilla/unused.h"
#include "nsPagePrintTimer.h"
#include "nsPrintEngine.h"
namespace mozilla {
namespace layout {
@ -29,8 +30,10 @@ RemotePrintJobChild::RecvPageProcessed()
bool
RemotePrintJobChild::RecvAbortPrint(const nsresult& aRv)
{
NS_NOTREACHED("RemotePrintJobChild::RecvAbortPrint not implemented!");
return false;
MOZ_ASSERT(mPrintEngine);
mPrintEngine->CleanupOnFailure(aRv, true);
return true;
}
void
@ -50,6 +53,14 @@ RemotePrintJobChild::SetPagePrintTimer(nsPagePrintTimer* aPagePrintTimer)
mPagePrintTimer = aPagePrintTimer;
}
void
RemotePrintJobChild::SetPrintEngine(nsPrintEngine* aPrintEngine)
{
MOZ_ASSERT(aPrintEngine);
mPrintEngine = aPrintEngine;
}
RemotePrintJobChild::~RemotePrintJobChild()
{
MOZ_COUNT_DTOR(RemotePrintJobChild);
@ -59,6 +70,7 @@ void
RemotePrintJobChild::ActorDestroy(ActorDestroyReason aWhy)
{
mPagePrintTimer = nullptr;
mPrintEngine = nullptr;
}
} // namespace layout

View File

@ -12,6 +12,7 @@
#include "mozilla/RefPtr.h"
class nsPagePrintTimer;
class nsPrintEngine;
namespace mozilla {
namespace layout {
@ -33,10 +34,13 @@ public:
void SetPagePrintTimer(nsPagePrintTimer* aPagePrintTimer);
void SetPrintEngine(nsPrintEngine* aPrintEngine);
private:
~RemotePrintJobChild() final;
RefPtr<nsPagePrintTimer> mPagePrintTimer;
RefPtr<nsPrintEngine> mPrintEngine;
};
} // namespace layout

View File

@ -3491,6 +3491,7 @@ nsPrintEngine::StartPagePrintTimer(nsPrintObject* aPO)
printSession->GetRemotePrintJob(getter_AddRefs(remotePrintJob));
if (NS_SUCCEEDED(rv) && remotePrintJob) {
remotePrintJob->SetPagePrintTimer(mPagePrintTimer);
remotePrintJob->SetPrintEngine(this);
}
}
}