Bug 1430682 - Use OwningNonNull for nsPagePrintTimer::mDocViewerPrint and remove null checks. r=bobowen
authorJonathan Watt <jwatt@jwatt.org>
Tue, 09 Jan 2018 22:21:53 +0000
changeset 399584 76ce0d94b9b75081a9f8842f4f157e3778b06f6b
parent 399583 1359c950dc758d408238074ef84363fb3a8051f4
child 399585 350aac55ed6402b20d1ca84f979bbd9b212683d2
push id33267
push usercsabou@mozilla.com
push dateWed, 17 Jan 2018 09:47:24 +0000
treeherdermozilla-central@4e429d313fd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
bugs1430682
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1430682 - Use OwningNonNull for nsPagePrintTimer::mDocViewerPrint and remove null checks. r=bobowen MozReview-Commit-ID: 5CPaYTA2PrC
layout/printing/nsPagePrintTimer.cpp
layout/printing/nsPagePrintTimer.h
--- a/layout/printing/nsPagePrintTimer.cpp
+++ b/layout/printing/nsPagePrintTimer.cpp
@@ -135,34 +135,32 @@ nsPagePrintTimer::Notify(nsITimer *timer
   } else if (timer == mWatchDogTimer) {
     mWatchDogCount++;
     if (mWatchDogCount > WATCH_DOG_MAX_COUNT) {
       Fail();
       return NS_OK;
     }
   }
 
-  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();
-    }
+  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();
-    }
+  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;
 }
 
 
 void
 nsPagePrintTimer::WaitForRemotePrint()
 {
   mWaitingForRemotePrint = NS_NewTimer();
--- a/layout/printing/nsPagePrintTimer.h
+++ b/layout/printing/nsPagePrintTimer.h
@@ -7,16 +7,17 @@
 #define nsPagePrintTimer_h___
 
 // Timer Includes
 #include "nsITimer.h"
 
 #include "nsIDocumentViewerPrint.h"
 #include "nsPrintObject.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/OwningNonNull.h"
 #include "nsThreadUtils.h"
 
 class nsPrintJob;
 class nsIDocument;
 
 //---------------------------------------------------
 //-- Page Timer Class
 //---------------------------------------------------
@@ -28,25 +29,25 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   nsPagePrintTimer(nsPrintJob* aPrintJob,
                    nsIDocumentViewerPrint* aDocViewerPrint,
                    nsIDocument* aDocument,
                    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();
   }
 
   NS_DECL_NSITIMERCALLBACK
 
   nsresult Start(nsPrintObject* aPO);
 
   NS_IMETHOD Run() override;
@@ -66,17 +67,17 @@ private:
   ~nsPagePrintTimer();
 
   nsresult StartTimer(bool aUseDelay);
   nsresult StartWatchDogTimer();
   void     StopWatchDogTimer();
   void     Fail();
 
   nsPrintJob*                mPrintJob;
-  nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
+  const mozilla::OwningNonNull<nsIDocumentViewerPrint> mDocViewerPrint;
   nsCOMPtr<nsIDocument>      mDocument;
   nsCOMPtr<nsITimer>         mTimer;
   nsCOMPtr<nsITimer>         mWatchDogTimer;
   nsCOMPtr<nsITimer>         mWaitingForRemotePrint;
   uint32_t                   mDelay;
   uint32_t                   mFiringCount;
   nsPrintObject *            mPrintObj;
   uint32_t                   mWatchDogCount;