Bumping gaia.json for 1 gaia revision(s) a=gaia-bump
[gecko.git] / layout / printing / nsPagePrintTimer.h
blobf7c211251fa05155880738b42fac7b8303eb5f28
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsPagePrintTimer_h___
6 #define nsPagePrintTimer_h___
8 // Timer Includes
9 #include "nsITimer.h"
11 #include "nsIDocumentViewerPrint.h"
12 #include "nsPrintObject.h"
13 #include "mozilla/Attributes.h"
14 #include "nsThreadUtils.h"
16 class nsPrintEngine;
18 //---------------------------------------------------
19 //-- Page Timer Class
20 //---------------------------------------------------
21 class nsPagePrintTimer MOZ_FINAL : public nsRunnable,
22 public nsITimerCallback
24 public:
26 NS_DECL_ISUPPORTS_INHERITED
28 nsPagePrintTimer(nsPrintEngine* aPrintEngine,
29 nsIDocumentViewerPrint* aDocViewerPrint,
30 uint32_t aDelay)
31 : mPrintEngine(aPrintEngine)
32 , mDocViewerPrint(aDocViewerPrint)
33 , mDelay(aDelay)
34 , mFiringCount(0)
35 , mPrintObj(nullptr)
36 , mWatchDogCount(0)
37 , mDone(false)
39 mDocViewerPrint->IncrementDestroyRefCount();
42 NS_DECL_NSITIMERCALLBACK
44 nsresult Start(nsPrintObject* aPO);
46 NS_IMETHOD Run() MOZ_OVERRIDE;
48 void Stop();
50 private:
51 ~nsPagePrintTimer();
53 nsresult StartTimer(bool aUseDelay);
54 nsresult StartWatchDogTimer();
55 void StopWatchDogTimer();
56 void Fail();
58 nsPrintEngine* mPrintEngine;
59 nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
60 nsCOMPtr<nsITimer> mTimer;
61 nsCOMPtr<nsITimer> mWatchDogTimer;
62 uint32_t mDelay;
63 uint32_t mFiringCount;
64 nsPrintObject * mPrintObj;
65 uint32_t mWatchDogCount;
66 bool mDone;
68 static const uint32_t WATCH_DOG_INTERVAL = 1000;
69 static const uint32_t WATCH_DOG_MAX_COUNT = 10;
73 nsresult
74 NS_NewPagePrintTimer(nsPagePrintTimer **aResult);
76 #endif /* nsPagePrintTimer_h___ */