Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | #ifndef nsPagePrintTimer_h___ |
michael@0 | 6 | #define nsPagePrintTimer_h___ |
michael@0 | 7 | |
michael@0 | 8 | // Timer Includes |
michael@0 | 9 | #include "nsITimer.h" |
michael@0 | 10 | |
michael@0 | 11 | #include "nsIDocumentViewerPrint.h" |
michael@0 | 12 | #include "nsPrintObject.h" |
michael@0 | 13 | #include "mozilla/Attributes.h" |
michael@0 | 14 | #include "nsThreadUtils.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsPrintEngine; |
michael@0 | 17 | |
michael@0 | 18 | //--------------------------------------------------- |
michael@0 | 19 | //-- Page Timer Class |
michael@0 | 20 | //--------------------------------------------------- |
michael@0 | 21 | class nsPagePrintTimer MOZ_FINAL : public nsRunnable, |
michael@0 | 22 | public nsITimerCallback |
michael@0 | 23 | { |
michael@0 | 24 | public: |
michael@0 | 25 | |
michael@0 | 26 | NS_DECL_ISUPPORTS |
michael@0 | 27 | |
michael@0 | 28 | nsPagePrintTimer(nsPrintEngine* aPrintEngine, |
michael@0 | 29 | nsIDocumentViewerPrint* aDocViewerPrint, |
michael@0 | 30 | uint32_t aDelay) |
michael@0 | 31 | : mPrintEngine(aPrintEngine) |
michael@0 | 32 | , mDocViewerPrint(aDocViewerPrint) |
michael@0 | 33 | , mDelay(aDelay) |
michael@0 | 34 | , mFiringCount(0) |
michael@0 | 35 | , mPrintObj(nullptr) |
michael@0 | 36 | , mWatchDogCount(0) |
michael@0 | 37 | , mDone(false) |
michael@0 | 38 | { |
michael@0 | 39 | mDocViewerPrint->IncrementDestroyRefCount(); |
michael@0 | 40 | } |
michael@0 | 41 | ~nsPagePrintTimer(); |
michael@0 | 42 | |
michael@0 | 43 | NS_DECL_NSITIMERCALLBACK |
michael@0 | 44 | |
michael@0 | 45 | nsresult Start(nsPrintObject* aPO); |
michael@0 | 46 | |
michael@0 | 47 | NS_IMETHOD Run() MOZ_OVERRIDE; |
michael@0 | 48 | |
michael@0 | 49 | void Stop(); |
michael@0 | 50 | |
michael@0 | 51 | private: |
michael@0 | 52 | nsresult StartTimer(bool aUseDelay); |
michael@0 | 53 | nsresult StartWatchDogTimer(); |
michael@0 | 54 | void StopWatchDogTimer(); |
michael@0 | 55 | void Fail(); |
michael@0 | 56 | |
michael@0 | 57 | nsPrintEngine* mPrintEngine; |
michael@0 | 58 | nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint; |
michael@0 | 59 | nsCOMPtr<nsITimer> mTimer; |
michael@0 | 60 | nsCOMPtr<nsITimer> mWatchDogTimer; |
michael@0 | 61 | uint32_t mDelay; |
michael@0 | 62 | uint32_t mFiringCount; |
michael@0 | 63 | nsPrintObject * mPrintObj; |
michael@0 | 64 | uint32_t mWatchDogCount; |
michael@0 | 65 | bool mDone; |
michael@0 | 66 | |
michael@0 | 67 | static const uint32_t WATCH_DOG_INTERVAL = 1000; |
michael@0 | 68 | static const uint32_t WATCH_DOG_MAX_COUNT = 10; |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | |
michael@0 | 72 | nsresult |
michael@0 | 73 | NS_NewPagePrintTimer(nsPagePrintTimer **aResult); |
michael@0 | 74 | |
michael@0 | 75 | #endif /* nsPagePrintTimer_h___ */ |