Bug 1428390 - Use mChildIsAlive to decide whether to send replies. r=jib
authorAndreas Pehrson <pehrsons@mozilla.com>
Mon, 08 Jan 2018 12:42:55 +0100
changeset 450330 640496b6e7c02d719eeadf8f2fc816a2e3a31157
parent 450329 2c9fc232f3cae5a3c9f6cddac1848eb551167a19
child 450331 c75357e076963d148e4c7453648438aa4e497a4c
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1428390
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 1428390 - Use mChildIsAlive to decide whether to send replies. r=jib MozReview-Commit-ID: BmpvYKo1tpJ
dom/media/systemservices/CamerasParent.cpp
--- a/dom/media/systemservices/CamerasParent.cpp
+++ b/dom/media/systemservices/CamerasParent.cpp
@@ -467,17 +467,17 @@ CamerasParent::RecvNumberOfCaptureDevice
       int num = -1;
       if (auto engine = self->EnsureInitialized(aCapEngine)) {
         if (auto devInfo = engine->GetOrCreateVideoCaptureDeviceInfo()) {
           num = devInfo->NumberOfDevices();
         }
       }
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, num]() -> nsresult {
-          if (self->IsShuttingDown()) {
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           if (num < 0) {
             LOG(("RecvNumberOfCaptureDevices couldn't find devices"));
             Unused << self->SendReplyFailure();
             return NS_ERROR_FAILURE;
           } else {
             LOG(("RecvNumberOfCaptureDevices: %d", num));
@@ -499,17 +499,17 @@ CamerasParent::RecvEnsureInitialized(con
 
   RefPtr<CamerasParent> self(this);
   RefPtr<Runnable> webrtc_runnable =
     media::NewRunnableFrom([self, aCapEngine]() -> nsresult {
       bool result = self->EnsureInitialized(aCapEngine);
 
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, result]() -> nsresult {
-          if (self->IsShuttingDown()) {
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           if (!result) {
             LOG(("RecvEnsureInitialized failed"));
             Unused << self->SendReplyFailure();
             return NS_ERROR_FAILURE;
           } else {
             LOG(("RecvEnsureInitialized succeeded"));
@@ -537,17 +537,17 @@ CamerasParent::RecvNumberOfCapabilities(
       int num = -1;
       if (auto engine = self->EnsureInitialized(aCapEngine)) {
         if (auto devInfo = engine->GetOrCreateVideoCaptureDeviceInfo()) {
           num = devInfo->NumberOfCapabilities(unique_id.get());
         }
       }
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, num]() -> nsresult {
-          if (self->IsShuttingDown()) {
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           if (num < 0) {
             LOG(("RecvNumberOfCapabilities couldn't find capabilities"));
             Unused << self->SendReplyFailure();
             return NS_ERROR_FAILURE;
           } else {
             LOG(("RecvNumberOfCapabilities: %d", num));
@@ -588,17 +588,17 @@ CamerasParent::RecvGetCaptureCapability(
             self->mAllCandidateCapabilities.emplace(nsCString(unique_id), candidateCapabilities);
           } else {
             (iter->second).emplace(num, webrtcCaps);
           }
         }
       }
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, webrtcCaps, error]() -> nsresult {
-          if (self->IsShuttingDown()) {
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           VideoCaptureCapability capCap(webrtcCaps.width,
                                    webrtcCaps.height,
                                    webrtcCaps.maxFPS,
                                    webrtcCaps.expectedCaptureDelay,
                                    webrtcCaps.rawType,
                                    webrtcCaps.codecType,
@@ -648,17 +648,17 @@ CamerasParent::RecvGetCaptureDevice(cons
         }
       }
       if (!error) {
         name.Assign(deviceName);
         uniqueId.Assign(deviceUniqueId);
       }
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, error, name, uniqueId, devicePid]() {
-          if (self->IsShuttingDown()) {
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           if (error) {
             LOG(("GetCaptureDevice failed: %d", error));
             Unused << self->SendReplyFailure();
             return NS_ERROR_FAILURE;
           }
           bool scary = (devicePid == getpid());
@@ -759,17 +759,17 @@ CamerasParent::RecvAllocateCaptureDevice
           engine->WithEntry(numdev, [&error](VideoEngine::CaptureEntry& cap) {
             if (cap.VideoCapture()) {
               error = 0;
             }
           });
         }
         RefPtr<nsIRunnable> ipc_runnable =
           media::NewRunnableFrom([self, numdev, error]() -> nsresult {
-            if (self->IsShuttingDown()) {
+            if (!self->mChildIsAlive) {
               return NS_ERROR_FAILURE;
             }
             if (error) {
               Unused << self->SendReplyFailure();
               return NS_ERROR_FAILURE;
             } else {
               LOG(("Allocated device nr %d", numdev));
               Unused << self->SendReplyAllocateCaptureDevice(numdev);
@@ -805,18 +805,17 @@ CamerasParent::RecvReleaseCaptureDevice(
   LOG(("RecvReleaseCamera device nr %d", numdev));
 
   RefPtr<CamerasParent> self(this);
   RefPtr<Runnable> webrtc_runnable =
     media::NewRunnableFrom([self, aCapEngine, numdev]() -> nsresult {
       int error = self->ReleaseCaptureDevice(aCapEngine, numdev);
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, error, numdev]() -> nsresult {
-          if (self->IsShuttingDown()) {
-            LOG(("In Shutdown, not Releasing"));
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           if (error) {
             Unused << self->SendReplyFailure();
             LOG(("Failed to free device nr %d", numdev));
             return NS_ERROR_FAILURE;
           } else {
             Unused << self->SendReplySuccess();
@@ -928,17 +927,17 @@ CamerasParent::RecvStartCapture(const Ca
           if (!error) {
             cap.VideoCapture()->RegisterCaptureDataCallback(
               static_cast<rtc::VideoSinkInterface<webrtc::VideoFrame>*>(*cbh));
           }
         });
       }
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, error]() -> nsresult {
-          if (self->IsShuttingDown()) {
+          if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }
           if (!error) {
             Unused << self->SendReplySuccess();
             return NS_OK;
           } else {
             Unused << self->SendReplyFailure();
             return NS_ERROR_FAILURE;
@@ -989,17 +988,17 @@ CamerasParent::RecvStopCapture(const Cap
 
   RefPtr<CamerasParent> self(this);
   RefPtr<Runnable> webrtc_runnable =
     media::NewRunnableFrom([self, aCapEngine, capnum]() -> nsresult {
       self->StopCapture(aCapEngine, capnum);
       return NS_OK;
     });
   nsresult rv = DispatchToVideoCaptureThread(webrtc_runnable);
-  if (self->IsShuttingDown()) {
+  if (!self->mChildIsAlive) {
     if (NS_FAILED(rv)) {
       return IPC_FAIL_NO_REASON(this);
     }
   } else {
     if (NS_SUCCEEDED(rv)) {
       if (!SendReplySuccess()) {
         return IPC_FAIL_NO_REASON(this);
       }