Bug 1419775 - Part 1.Prevent send IPC message when cancelling the print job if IPC connection already closed. r=mconley
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Wed, 10 Jan 2018 09:00:10 +0900
changeset 452817 f466c92f42bf5ba5d081af0cfd4ff13067264fc5
parent 452816 5b6bf3714f4eb4c3a7e6f00558211e7b84db9866
child 452818 54fefcd4dc6276ffc69fcb0458c06acbefdcae05
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1419775
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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