no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / printing / nsPagePrintTimer.h
blob068d9fafb7dbbca2de5228e78a3a269abab2df6e
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___
9 // Timer Includes
10 #include "nsITimer.h"
12 #include "nsIDocumentViewerPrint.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/OwningNonNull.h"
15 #include "nsThreadUtils.h"
17 class nsPrintJob;
18 class nsPrintObject;
20 namespace mozilla::dom {
21 class Document;
24 //---------------------------------------------------
25 //-- Page Timer Class
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 {
33 public:
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;
46 void Stop();
48 void WaitForRemotePrint();
49 void RemotePrintFinished();
51 void Disconnect();
53 private:
54 ~nsPagePrintTimer();
56 nsresult StartTimer(bool aUseDelay);
57 nsresult StartWatchDogTimer();
58 void StopWatchDogTimer();
59 void Fail();
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;
67 uint32_t mDelay;
68 uint32_t mFiringCount;
69 nsPrintObject* mPrintObj;
70 uint32_t mWatchDogCount;
71 bool mDone;
73 static const uint32_t WATCH_DOG_INTERVAL = 1000;
74 static const uint32_t WATCH_DOG_MAX_COUNT =
75 #ifdef DEBUG
76 // Debug builds are very slow (on Mac at least) and can need extra time
78 #else
80 #endif
84 #endif /* nsPagePrintTimer_h___ */