/src/mozilla-central/layout/printing/nsPagePrintTimer.h
Line | Count | Source (jump to first uncovered line) |
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___ |
8 | | |
9 | | // Timer Includes |
10 | | #include "nsITimer.h" |
11 | | |
12 | | #include "nsIDocumentViewerPrint.h" |
13 | | #include "nsPrintObject.h" |
14 | | #include "mozilla/Attributes.h" |
15 | | #include "mozilla/OwningNonNull.h" |
16 | | #include "nsThreadUtils.h" |
17 | | |
18 | | class nsPrintJob; |
19 | | class nsIDocument; |
20 | | |
21 | | //--------------------------------------------------- |
22 | | //-- Page Timer Class |
23 | | //--------------------------------------------------- |
24 | | class nsPagePrintTimer final : public mozilla::Runnable, |
25 | | public nsITimerCallback |
26 | | { |
27 | | public: |
28 | | |
29 | | NS_DECL_ISUPPORTS_INHERITED |
30 | | |
31 | | nsPagePrintTimer(nsPrintJob* aPrintJob, |
32 | | nsIDocumentViewerPrint* aDocViewerPrint, |
33 | | nsIDocument* aDocument, |
34 | | uint32_t aDelay) |
35 | | : Runnable("nsPagePrintTimer") |
36 | | , mPrintJob(aPrintJob) |
37 | | , mDocViewerPrint(*aDocViewerPrint) |
38 | | , mDocument(aDocument) |
39 | | , mDelay(aDelay) |
40 | | , mFiringCount(0) |
41 | | , mPrintObj(nullptr) |
42 | | , mWatchDogCount(0) |
43 | | , mDone(false) |
44 | 0 | { |
45 | 0 | MOZ_ASSERT(aDocViewerPrint && aDocument); |
46 | 0 | mDocViewerPrint->IncrementDestroyBlockedCount(); |
47 | 0 | } |
48 | | |
49 | | NS_DECL_NSITIMERCALLBACK |
50 | | |
51 | | nsresult Start(nsPrintObject* aPO); |
52 | | |
53 | | NS_IMETHOD Run() override; |
54 | | |
55 | | void Stop(); |
56 | | |
57 | | void WaitForRemotePrint(); |
58 | | void RemotePrintFinished(); |
59 | | |
60 | | void Disconnect() |
61 | 0 | { |
62 | 0 | mPrintJob = nullptr; |
63 | 0 | mPrintObj = nullptr; |
64 | 0 | } |
65 | | |
66 | | private: |
67 | | ~nsPagePrintTimer(); |
68 | | |
69 | | nsresult StartTimer(bool aUseDelay); |
70 | | nsresult StartWatchDogTimer(); |
71 | | void StopWatchDogTimer(); |
72 | | void Fail(); |
73 | | |
74 | | nsPrintJob* mPrintJob; |
75 | | const mozilla::OwningNonNull<nsIDocumentViewerPrint> mDocViewerPrint; |
76 | | nsCOMPtr<nsIDocument> mDocument; |
77 | | nsCOMPtr<nsITimer> mTimer; |
78 | | nsCOMPtr<nsITimer> mWatchDogTimer; |
79 | | nsCOMPtr<nsITimer> mWaitingForRemotePrint; |
80 | | uint32_t mDelay; |
81 | | uint32_t mFiringCount; |
82 | | nsPrintObject * mPrintObj; |
83 | | uint32_t mWatchDogCount; |
84 | | bool mDone; |
85 | | |
86 | | static const uint32_t WATCH_DOG_INTERVAL = 1000; |
87 | | static const uint32_t WATCH_DOG_MAX_COUNT = |
88 | | #ifdef DEBUG |
89 | | // Debug builds are very slow (on Mac at least) and can need extra time |
90 | | 30 |
91 | | #else |
92 | | 10 |
93 | | #endif |
94 | | ; |
95 | | }; |
96 | | |
97 | | #endif /* nsPagePrintTimer_h___ */ |