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 "mozilla/Attributes.h"
14 #include "mozilla/OwningNonNull.h"
15 #include "nsThreadUtils.h"
20 namespace mozilla::dom
{
24 //---------------------------------------------------
26 //---------------------------------------------------
27 // Strictly speaking, this actually manages the timing of printing *sheets*
28 // (instances of "PrintedSheetFrame"), each of which may encompass multiple
29 // pages (nsPageFrames) of the document. The use of "Page" in the class name
30 // here is for historical / colloquial purposes.
31 class nsPagePrintTimer final
: public mozilla::Runnable
,
32 public nsITimerCallback
{
34 NS_DECL_ISUPPORTS_INHERITED
36 nsPagePrintTimer(nsPrintJob
* aPrintJob
,
37 nsIDocumentViewerPrint
* aDocViewerPrint
,
38 mozilla::dom::Document
* aDocument
, uint32_t aDelay
);
40 NS_DECL_NSITIMERCALLBACK
42 nsresult
Start(nsPrintObject
* aPO
);
44 NS_IMETHOD
Run() override
;
48 void WaitForRemotePrint();
49 void RemotePrintFinished();
56 nsresult
StartTimer(bool aUseDelay
);
57 nsresult
StartWatchDogTimer();
58 void StopWatchDogTimer();
61 nsPrintJob
* mPrintJob
;
62 nsCOMPtr
<nsIDocumentViewerPrint
> mDocViewerPrint
;
63 RefPtr
<mozilla::dom::Document
> mDocument
;
64 nsCOMPtr
<nsITimer
> mTimer
;
65 nsCOMPtr
<nsITimer
> mWatchDogTimer
;
66 nsCOMPtr
<nsITimer
> mWaitingForRemotePrint
;
68 uint32_t mFiringCount
;
69 nsPrintObject
* mPrintObj
;
70 uint32_t mWatchDogCount
;
73 static const uint32_t WATCH_DOG_INTERVAL
= 1000;
74 static const uint32_t WATCH_DOG_MAX_COUNT
=
76 // Debug builds are very slow (on Mac at least) and can need extra time
84 #endif /* nsPagePrintTimer_h___ */