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 7 #ifndef mozilla_layout_RemotePrintJobParent_h 8 #define mozilla_layout_RemotePrintJobParent_h 9 10 #include "mozilla/layout/PRemotePrintJobParent.h" 11 #include "mozilla/layout/printing/DrawEventRecorder.h" 12 13 #include "nsCOMArray.h" 14 #include "nsCOMPtr.h" 15 #include "mozilla/RefPtr.h" 16 #include "mozilla/UniquePtr.h" 17 #include "mozilla/gfx/RecordedEvent.h" 18 19 class nsDeviceContext; 20 class nsIPrintSettings; 21 class nsIWebProgressListener; 22 23 namespace mozilla { 24 namespace layout { 25 26 class PrintTranslator; 27 28 class RemotePrintJobParent final : public PRemotePrintJobParent { 29 public: 30 explicit RemotePrintJobParent(nsIPrintSettings* aPrintSettings); 31 32 void ActorDestroy(ActorDestroyReason aWhy) final; 33 34 mozilla::ipc::IPCResult RecvInitializePrint(const nsString& aDocumentTitle, 35 const nsString& aPrintToFile, 36 const int32_t& aStartPage, 37 const int32_t& aEndPage) final; 38 39 mozilla::ipc::IPCResult RecvProcessPage() final; 40 41 mozilla::ipc::IPCResult RecvFinalizePrint() final; 42 43 mozilla::ipc::IPCResult RecvAbortPrint(const nsresult& aRv) final; 44 45 mozilla::ipc::IPCResult RecvStateChange(const long& aStateFlags, 46 const nsresult& aStatus) final; 47 48 mozilla::ipc::IPCResult RecvProgressChange( 49 const long& aCurSelfProgress, const long& aMaxSelfProgress, 50 const long& aCurTotalProgress, const long& aMaxTotalProgress) final; 51 52 mozilla::ipc::IPCResult RecvStatusChange(const nsresult& aStatus) final; 53 54 /** 55 * Register a progress listener to receive print progress updates. 56 * 57 * @param aListener the progress listener to register. Must not be null. 58 */ 59 void RegisterListener(nsIWebProgressListener* aListener); 60 61 /** 62 * @return the print settings for this remote print job. 63 */ 64 already_AddRefed<nsIPrintSettings> GetPrintSettings(); 65 66 private: 67 ~RemotePrintJobParent() final; 68 69 nsresult InitializePrintDevice(const nsString& aDocumentTitle, 70 const nsString& aPrintToFile, 71 const int32_t& aStartPage, 72 const int32_t& aEndPage); 73 74 nsresult PrepareNextPageFD(FileDescriptor* aFd); 75 76 nsresult PrintPage(PRFileDescStream& aRecording); 77 78 /** 79 * Called to notify our corresponding RemotePrintJobChild once we've 80 * finished printing a page. 81 */ 82 void PageDone(nsresult aResult); 83 84 nsCOMPtr<nsIPrintSettings> mPrintSettings; 85 RefPtr<nsDeviceContext> mPrintDeviceContext; 86 UniquePtr<PrintTranslator> mPrintTranslator; 87 nsCOMArray<nsIWebProgressListener> mPrintProgressListeners; 88 PRFileDescStream mCurrentPageStream; 89 bool mIsDoingPrinting; 90 }; 91 92 } // namespace layout 93 } // namespace mozilla 94 95 #endif // mozilla_layout_RemotePrintJobParent_h 96