Bug 1419775 - Part 1.Prevent send IPC message when cancelling the print job if IPC connection already closed. r?mconley draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Wed, 10 Jan 2018 09:00:10 +0900
changeset 718272 e20dae56804641b399a4d2cb309b6709643448e2
parent 717422 05fed903f40f05fd923ba2137696ecc1fa0bafe6
child 718273 ab1901a7b387d58b671cba3bbfe10633b5930821
push id94854
push userbmo:mantaroh@gmail.com
push dateWed, 10 Jan 2018 00:04:13 +0000
reviewersmconley
bugs1419775
milestone59.0a1
Bug 1419775 - Part 1.Prevent send IPC message when cancelling the print job if IPC connection already closed. r?mconley If target content tab is already closed, progress dialog can't notify to content process that cancelling the print job. So this patch will prevent send cancelling message in this case. MozReview-Commit-ID: 7G1LACajVha
toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
--- a/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
+++ b/toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp
@@ -75,41 +75,43 @@ PrintProgressDialogParent::RecvDocURLCha
     mPrintProgressParams->SetDocURL(newURL);
   }
   return IPC_OK();
 }
 
 void
 PrintProgressDialogParent::ActorDestroy(ActorDestroyReason aWhy)
 {
+  // If IPC actor is destroyed, we can't send to child via IPC.
+  mActive = false;
 }
 
 mozilla::ipc::IPCResult
 PrintProgressDialogParent::Recv__delete__()
 {
   // The child has requested that we tear down the connection, so we set a
   // member to make sure we don't try to contact it after the fact.
   mActive = false;
   return IPC_OK();
 }
 
 // nsIObserver
 NS_IMETHODIMP
 PrintProgressDialogParent::Observe(nsISupports *aSubject, const char *aTopic,
                                    const char16_t *aData)
 {
-  if (aTopic && !strcmp(aTopic, "cancelled")) {
-    Unused << SendCancelledCurrentJob();
-  } else {
-    if (mActive) {
+  if (mActive) {
+    if (aTopic && !strcmp(aTopic, "cancelled")) {
+      Unused << SendCancelledCurrentJob();
+    } else {
       Unused << SendDialogOpened();
-    } else {
-      NS_WARNING("The print progress dialog finished opening, but communications "
-                 "with the child have been closed.");
     }
+  } else {
+    NS_WARNING("The print progress dialog finished opening, but communications "
+               "with the child have been closed.");
   }
 
   return NS_OK;
 }
 
 
 } // namespace embedding
 } // namespace mozilla