Bug 1399787 - Part 8. Handle PDFium process crash. draft
authorcku <cku@mozilla.com>
Wed, 18 Oct 2017 18:01:51 +0800
changeset 682391 0f7b720b4a633bcdce5a1f8fd52c89edb4932c5b
parent 682390 f4a719d2d471663490edef1655a594ada89b59ef
child 682392 f634d3800e7cfbf6c8f42eb620bf9a1cd12ffab6
push id85086
push usercku@mozilla.com
push dateWed, 18 Oct 2017 14:51:34 +0000
bugs1399787
milestone58.0a1
Bug 1399787 - Part 8. Handle PDFium process crash. MozReview-Commit-ID: FkiCSVsx0kv
widget/windows/PDFiumParent.cpp
widget/windows/nsDeviceContextSpecWin.h
--- a/widget/windows/PDFiumParent.cpp
+++ b/widget/windows/PDFiumParent.cpp
@@ -23,16 +23,20 @@ bool
 PDFiumParent::Init(IPC::Channel* aChannel, base::ProcessId aPid)
 {
   return Open(aChannel,aPid);
 }
 
 void
 PDFiumParent::ActorDestroy(ActorDestroyReason aWhy)
 {
+  NS_DispatchToCurrentThread(NewRunnableMethod(
+    "nsDeviceContextSpecWin::CleanupPrintViaPDF",
+     mDevSpecWin,
+     &nsDeviceContextSpecWin::CleanupPrintViaPDF));
 }
 
 mozilla::ipc::IPCResult
 PDFiumParent::RecvNotifyPageCount(const int& aPageCount)
 {
   mDevSpecWin->SetPDFPageCount(aPageCount);
   return IPC_OK();
 }
--- a/widget/windows/nsDeviceContextSpecWin.h
+++ b/widget/windows/nsDeviceContextSpecWin.h
@@ -64,16 +64,17 @@ public:
 
   // helper functions
   nsresult GetDataFromPrinter(const nsAString& aName,
                               nsIPrintSettings* aPS = nullptr);
 
 #ifdef MOZ_ENABLE_SKIA_PDF
   void SetPDFPageCount(int aPageCount);
   void PrintEMF(const nsString& aFilePath);
+  void CleanupPrintViaPDF();
 #endif
 
 protected:
 
   void SetDeviceName(const nsAString& aDeviceName);
   void SetDriverName(const nsAString& aDriverName);
   void SetDevMode(LPDEVMODEW aDevMode);
 
@@ -83,17 +84,16 @@ protected:
   nsString mDeviceName;
   LPDEVMODEW mDevMode;
 
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
   int16_t mOutputFormat = nsIPrintSettings::kOutputFormatNative;
 
 #ifdef MOZ_ENABLE_SKIA_PDF
   void  FinishPrintViaPDF(nsString aFilePath);
-  void  CleanupPrintViaPDF();
 
   // This variable is independant of nsIPrintSettings::kOutputFormatPDF.
   // It controls both whether normal printing is done via PDF using Skia and
   // whether print-to-PDF uses Skia.
   bool mPrintViaSkPDF;
   nsCOMPtr<nsIFile> mPDFTempFile;
   HDC mDC;
   bool mPrintViaPDFInProgress;