Bug 1637114 [wpt PR 23518] - Handle k-rate AudioParam inputs for AudioWorkletNode...
[gecko.git] / layout / printing / nsPagePrintTimer.h
blob7004165878840cbbd912a082ddf725e88ddf4d1c
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 "nsPrintObject.h"
14 #include "mozilla/Attributes.h"
15 #include "mozilla/OwningNonNull.h"
16 #include "nsThreadUtils.h"
18 class nsPrintJob;
20 //---------------------------------------------------
21 //-- Page Timer Class
22 //---------------------------------------------------
23 class nsPagePrintTimer final : public mozilla::Runnable,
24 public nsITimerCallback {
25 public:
26 NS_DECL_ISUPPORTS_INHERITED
28 nsPagePrintTimer(nsPrintJob* aPrintJob,
29 nsIDocumentViewerPrint* aDocViewerPrint,
30 mozilla::dom::Document* aDocument, uint32_t aDelay)
31 : Runnable("nsPagePrintTimer"),
32 mPrintJob(aPrintJob),
33 mDocViewerPrint(*aDocViewerPrint),
34 mDocument(aDocument),
35 mDelay(aDelay),
36 mFiringCount(0),
37 mPrintObj(nullptr),
38 mWatchDogCount(0),
39 mDone(false) {
40 MOZ_ASSERT(aDocViewerPrint && aDocument);
41 mDocViewerPrint->IncrementDestroyBlockedCount();
44 NS_DECL_NSITIMERCALLBACK
46 nsresult Start(nsPrintObject* aPO);
48 NS_IMETHOD Run() override;
50 void Stop();
52 void WaitForRemotePrint();
53 void RemotePrintFinished();
55 void Disconnect() {
56 mPrintJob = nullptr;
57 mPrintObj = nullptr;
60 private:
61 ~nsPagePrintTimer();
63 nsresult StartTimer(bool aUseDelay);
64 nsresult StartWatchDogTimer();
65 void StopWatchDogTimer();
66 void Fail();
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;
74 uint32_t mDelay;
75 uint32_t mFiringCount;
76 nsPrintObject* mPrintObj;
77 uint32_t mWatchDogCount;
78 bool mDone;
80 static const uint32_t WATCH_DOG_INTERVAL = 1000;
81 static const uint32_t WATCH_DOG_MAX_COUNT =
82 #ifdef DEBUG
83 // Debug builds are very slow (on Mac at least) and can need extra time
85 #else
87 #endif
91 #endif /* nsPagePrintTimer_h___ */