1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsPagePrintTimer_h___
7 #define nsPagePrintTimer_h___
12 #include "nsIDocumentViewerPrint.h"
13 #include "nsPrintObject.h"
14 #include "mozilla/Attributes.h"
15 #include "mozilla/OwningNonNull.h"
16 #include "nsThreadUtils.h"
20 //---------------------------------------------------
22 //---------------------------------------------------
23 class nsPagePrintTimer final
: public mozilla::Runnable
,
24 public nsITimerCallback
{
26 NS_DECL_ISUPPORTS_INHERITED
28 nsPagePrintTimer(nsPrintJob
* aPrintJob
,
29 nsIDocumentViewerPrint
* aDocViewerPrint
,
30 mozilla::dom::Document
* aDocument
, uint32_t aDelay
)
31 : Runnable("nsPagePrintTimer"),
33 mDocViewerPrint(*aDocViewerPrint
),
40 MOZ_ASSERT(aDocViewerPrint
&& aDocument
);
41 mDocViewerPrint
->IncrementDestroyBlockedCount();
44 NS_DECL_NSITIMERCALLBACK
46 nsresult
Start(nsPrintObject
* aPO
);
48 NS_IMETHOD
Run() override
;
52 void WaitForRemotePrint();
53 void RemotePrintFinished();
63 nsresult
StartTimer(bool aUseDelay
);
64 nsresult
StartWatchDogTimer();
65 void StopWatchDogTimer();
68 nsPrintJob
* mPrintJob
;
69 const mozilla::OwningNonNull
<nsIDocumentViewerPrint
> mDocViewerPrint
;
70 RefPtr
<mozilla::dom::Document
> mDocument
;
71 nsCOMPtr
<nsITimer
> mTimer
;
72 nsCOMPtr
<nsITimer
> mWatchDogTimer
;
73 nsCOMPtr
<nsITimer
> mWaitingForRemotePrint
;
75 uint32_t mFiringCount
;
76 nsPrintObject
* mPrintObj
;
77 uint32_t mWatchDogCount
;
80 static const uint32_t WATCH_DOG_INTERVAL
= 1000;
81 static const uint32_t WATCH_DOG_MAX_COUNT
=
83 // Debug builds are very slow (on Mac at least) and can need extra time
91 #endif /* nsPagePrintTimer_h___ */