1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/printing/nsPagePrintTimer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#ifndef nsPagePrintTimer_h___ 1.9 +#define nsPagePrintTimer_h___ 1.10 + 1.11 +// Timer Includes 1.12 +#include "nsITimer.h" 1.13 + 1.14 +#include "nsIDocumentViewerPrint.h" 1.15 +#include "nsPrintObject.h" 1.16 +#include "mozilla/Attributes.h" 1.17 +#include "nsThreadUtils.h" 1.18 + 1.19 +class nsPrintEngine; 1.20 + 1.21 +//--------------------------------------------------- 1.22 +//-- Page Timer Class 1.23 +//--------------------------------------------------- 1.24 +class nsPagePrintTimer MOZ_FINAL : public nsRunnable, 1.25 + public nsITimerCallback 1.26 +{ 1.27 +public: 1.28 + 1.29 + NS_DECL_ISUPPORTS 1.30 + 1.31 + nsPagePrintTimer(nsPrintEngine* aPrintEngine, 1.32 + nsIDocumentViewerPrint* aDocViewerPrint, 1.33 + uint32_t aDelay) 1.34 + : mPrintEngine(aPrintEngine) 1.35 + , mDocViewerPrint(aDocViewerPrint) 1.36 + , mDelay(aDelay) 1.37 + , mFiringCount(0) 1.38 + , mPrintObj(nullptr) 1.39 + , mWatchDogCount(0) 1.40 + , mDone(false) 1.41 + { 1.42 + mDocViewerPrint->IncrementDestroyRefCount(); 1.43 + } 1.44 + ~nsPagePrintTimer(); 1.45 + 1.46 + NS_DECL_NSITIMERCALLBACK 1.47 + 1.48 + nsresult Start(nsPrintObject* aPO); 1.49 + 1.50 + NS_IMETHOD Run() MOZ_OVERRIDE; 1.51 + 1.52 + void Stop(); 1.53 + 1.54 +private: 1.55 + nsresult StartTimer(bool aUseDelay); 1.56 + nsresult StartWatchDogTimer(); 1.57 + void StopWatchDogTimer(); 1.58 + void Fail(); 1.59 + 1.60 + nsPrintEngine* mPrintEngine; 1.61 + nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint; 1.62 + nsCOMPtr<nsITimer> mTimer; 1.63 + nsCOMPtr<nsITimer> mWatchDogTimer; 1.64 + uint32_t mDelay; 1.65 + uint32_t mFiringCount; 1.66 + nsPrintObject * mPrintObj; 1.67 + uint32_t mWatchDogCount; 1.68 + bool mDone; 1.69 + 1.70 + static const uint32_t WATCH_DOG_INTERVAL = 1000; 1.71 + static const uint32_t WATCH_DOG_MAX_COUNT = 10; 1.72 +}; 1.73 + 1.74 + 1.75 +nsresult 1.76 +NS_NewPagePrintTimer(nsPagePrintTimer **aResult); 1.77 + 1.78 +#endif /* nsPagePrintTimer_h___ */