Skip to content

Commit

Permalink
Bug 1430682 - Use OwningNonNull for nsPagePrintTimer::mDocViewerPrint…
Browse files Browse the repository at this point in the history
… and remove null checks. r=bobowen

MozReview-Commit-ID: 5CPaYTA2PrC
  • Loading branch information
jwatt committed Jan 9, 2018
1 parent 706256a commit e04dd66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
30 changes: 14 additions & 16 deletions layout/printing/nsPagePrintTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,22 @@ nsPagePrintTimer::Notify(nsITimer *timer)
}
}

if (mDocViewerPrint) {
bool donePrePrint = true;
// Don't start to pre-print if we're waiting on the parent still.
if (mPrintJob && !mWaitingForRemotePrint) {
donePrePrint = mPrintJob->PrePrintPage();
}

if (donePrePrint && !mWaitingForRemotePrint) {
StopWatchDogTimer();
// Pass nullptr here since name already was set in constructor.
mDocument->Dispatch(TaskCategory::Other, do_AddRef(this));
} else {
// Start the watch dog if we're waiting for preprint to ensure that if any
// mozPrintCallbacks take to long we error out.
StartWatchDogTimer();
}
bool donePrePrint = true;
// Don't start to pre-print if we're waiting on the parent still.
if (mPrintJob && !mWaitingForRemotePrint) {
donePrePrint = mPrintJob->PrePrintPage();
}

if (donePrePrint && !mWaitingForRemotePrint) {
StopWatchDogTimer();
// Pass nullptr here since name already was set in constructor.
mDocument->Dispatch(TaskCategory::Other, do_AddRef(this));
} else {
// Start the watch dog if we're waiting for preprint to ensure that if any
// mozPrintCallbacks take to long we error out.
StartWatchDogTimer();
}

return NS_OK;
}

Expand Down
7 changes: 4 additions & 3 deletions layout/printing/nsPagePrintTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "nsIDocumentViewerPrint.h"
#include "nsPrintObject.h"
#include "mozilla/Attributes.h"
#include "mozilla/OwningNonNull.h"
#include "nsThreadUtils.h"

class nsPrintJob;
Expand All @@ -33,15 +34,15 @@ class nsPagePrintTimer final : public mozilla::Runnable,
uint32_t aDelay)
: Runnable("nsPagePrintTimer")
, mPrintJob(aPrintJob)
, mDocViewerPrint(aDocViewerPrint)
, mDocViewerPrint(*aDocViewerPrint)
, mDocument(aDocument)
, mDelay(aDelay)
, mFiringCount(0)
, mPrintObj(nullptr)
, mWatchDogCount(0)
, mDone(false)
{
MOZ_ASSERT(aDocument);
MOZ_ASSERT(aDocViewerPrint && aDocument);
mDocViewerPrint->IncrementDestroyBlockedCount();
}

Expand Down Expand Up @@ -71,7 +72,7 @@ class nsPagePrintTimer final : public mozilla::Runnable,
void Fail();

nsPrintJob* mPrintJob;
nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
const mozilla::OwningNonNull<nsIDocumentViewerPrint> mDocViewerPrint;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<nsITimer> mWatchDogTimer;
Expand Down

0 comments on commit e04dd66

Please sign in to comment.