tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RemotePrintJobParent.h (3460B)


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