mozilla::ipc::IPCResult
TemporaryIPCBlobParent::RecvOperationDone(const nsCString& aContentType,
                                          const FileDescriptor& aFD)
{
  MOZ_ASSERT(mActive);
  mActive = false;

  // We have received a file descriptor because in this way we have kept the
  // file locked on windows during the IPC communication. After the creation of
  // the TemporaryFileBlobImpl, this prfile can be closed.
  auto rawFD = aFD.ClonePlatformHandle();
  PRFileDesc* prfile = PR_ImportFile(PROsfd(rawFD.release()));

  // Let's create the BlobImpl.
  nsCOMPtr<nsIFile> file = Move(mFile);

  RefPtr<TemporaryFileBlobImpl> blobImpl =
    new TemporaryFileBlobImpl(file, NS_ConvertUTF8toUTF16(aContentType));

  PR_Close(prfile);

  IPCBlob ipcBlob;
  nsresult rv = IPCBlobUtils::Serialize(blobImpl, Manager(), ipcBlob);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    Unused << Send__delete__(this, NS_ERROR_FAILURE);
    return IPC_OK();
  }

  Unused << Send__delete__(this, ipcBlob);
  return IPC_OK();
}
bool
SendStreamParentImpl::RecvClose(const nsresult& aRv)
{
  mWriter->CloseWithStatus(aRv);
  Unused << Send__delete__(this);
  return true;
}
NS_IMETHODIMP
WebBrowserPersistResourcesChild::EndVisit(nsIWebBrowserPersistDocument *aDocument,
                                          nsresult aStatus)
{
    Send__delete__(this, aStatus);
    return NS_OK;
}
NS_IMETHODIMP
TelephonyRequestParent::EnumerateCallStateComplete()
{
    NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);

    return Send__delete__(this, EnumerateCallsResponse()) ? NS_OK : NS_ERROR_FAILURE;
}
void
FTPChannelChild::DoOnStopRequest(const nsresult& statusCode)
{
  LOG(("FTPChannelChild::RecvOnStopRequest [this=%x status=%u]\n",
           this, statusCode));

  if (!mCanceled)
    mStatus = statusCode;

  { // Ensure that all queued ipdl events are dispatched before
    // we initiate protocol deletion below.
    mIsPending = PR_FALSE;
    AutoEventEnqueuer ensureSerialDispatch(this);
    (void)mListener->OnStopRequest(this, mListenerContext, statusCode);
    mListener = nsnull;
    mListenerContext = nsnull;

    if (mLoadGroup)
      mLoadGroup->RemoveRequest(this, nsnull, statusCode);
  }

  // This calls NeckoChild::DeallocPFTPChannel(), which deletes |this| if IPDL
  // holds the last reference.  Don't rely on |this| existing after here!
  Send__delete__(this);
}
bool
GMPVideoDecoderChild::RecvDecodingComplete()
{
  MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());

  if (mNeedShmemIntrCount) {
    // There's a GMP blocked in Alloc() waiting for the CallNeedShem() to
    // return a frame they can use. Don't call the GMP's DecodingComplete()
    // now and don't delete the GMPVideoDecoderChild, defer processing the
    // DecodingComplete() until once the Alloc() finishes.
    mPendingDecodeComplete = true;
    return true;
  }
  if (mVideoDecoder) {
    // Ignore any return code. It is OK for this to fail without killing the process.
    mVideoDecoder->DecodingComplete();
    mVideoDecoder = nullptr;
  }

  mVideoHost.DoneWithAPI();

  mPlugin = nullptr;

  Unused << Send__delete__(this);

  return true;
}
Exemple #7
0
nsresult
IccRequestParent::SendReply(const IccReply& aReply)
{
  NS_ENSURE_TRUE(mIcc, NS_ERROR_FAILURE);

  return Send__delete__(this, aReply) ? NS_OK : NS_ERROR_FAILURE;
}
already_AddRefed<IPCBlobInputStream>
IPCBlobInputStreamChild::CreateStream()
{
  bool shouldMigrate = false;

  RefPtr<IPCBlobInputStream> stream = new IPCBlobInputStream(this);

  {
    MutexAutoLock lock(mMutex);

    if (mState == eInactive) {
      return nullptr;
    }

    // The stream is active but maybe it is not running in the DOM-File thread.
    // We should migrate it there.
    if (mState == eActive &&
        !IPCBlobInputStreamThread::IsOnFileEventTarget(mOwningEventTarget)) {
      MOZ_ASSERT(mStreams.IsEmpty());
      shouldMigrate = true;
      mState = eActiveMigrating;
    }

    mStreams.AppendElement(stream);
  }

  // Send__delete__ will call ActorDestroy(). mMutex cannot be locked at this
  // time.
  if (shouldMigrate) {
    Send__delete__(this);
  }

  return stream.forget();
}
mozilla::ipc::IPCResult
SendStreamParentImpl::RecvClose(const nsresult& aRv)
{
  mWriter->CloseWithStatus(aRv);
  Unused << Send__delete__(this);
  return IPC_OK();
}
bool
GamepadTestChannelParent::RecvShutdownChannel()
{
  mShuttingdown = true;
  Unused << Send__delete__(this);
  return true;
}
nsresult
TelephonyRequestParent::SendResponse(const IPCTelephonyResponse& aResponse)
{
    NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);

    return Send__delete__(this, aResponse) ? NS_OK : NS_ERROR_FAILURE;
}
mozilla::ipc::IPCResult
GamepadTestChannelParent::RecvShutdownChannel()
{
  mShuttingdown = true;
  Unused << Send__delete__(this);
  return IPC_OK();
}
void
SmsRequestParent::SendReply(const MessageReply& aReply) {
  nsRefPtr<SmsRequest> request;
  mSmsRequest.swap(request);
  if (!Send__delete__(this, aReply)) {
    NS_WARNING("Failed to send response to child process!");
  }
}
void
PaymentRequestChild::MaybeDelete()
{
  if (mActorAlive) {
    mActorAlive = false;
    Send__delete__(this);
  }
}
mozilla::ipc::IPCResult MIDIPortParent::RecvShutdown() {
  if (mShuttingDown) {
    return IPC_OK();
  }
  Teardown();
  Unused << Send__delete__(this);
  return IPC_OK();
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialError(const nsAString& aError)
{
  NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);

  return (SendNotifyDialError(nsString(aError)) &&
          Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE;
}
nsresult
PresentationRequestParent::SendResponse(nsresult aResult)
{
  if (NS_WARN_IF(mActorDestroyed || !Send__delete__(this, aResult))) {
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}
mozilla::ipc::IPCResult
PSMContentDownloaderParent::RecvDivertToParentUsing(mozilla::net::PChannelDiverterParent* diverter)
{
  MOZ_ASSERT(diverter);
  auto p = static_cast<mozilla::net::ChannelDiverterParent*>(diverter);
  p->DivertTo(this);
  mozilla::Unused << p->Send__delete__(p);
  return IPC_OK();
}
bool
PSMContentDownloaderParent::RecvDivertToParentUsing(mozilla::net::PChannelDiverterParent* diverter)
{
  MOZ_ASSERT(diverter);
  auto p = static_cast<mozilla::net::ChannelDiverterParent*>(diverter);
  p->DivertTo(this);
  mozilla::unused << p->Send__delete__(p);
  return true;
}
NS_IMETHODIMP
TelephonyRequestParent::NotifyDialSuccess(uint32_t aCallIndex,
                                          const nsAString& aNumber)
{
  NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);

  return (SendNotifyDialSuccess(aCallIndex, nsString(aNumber)) &&
          Send__delete__(this, DialResponse())) ? NS_OK : NS_ERROR_FAILURE;
}
mozilla::ipc::IPCResult
TemporaryIPCBlobParent::SendDeleteError(nsresult aRv)
{
  MOZ_ASSERT(mActive);
  mActive = false;

  Unused << Send__delete__(this, aRv);
  return IPC_OK();
}
Exemple #22
0
void ImageContainerChild::DestroyNow()
{
  NS_ABORT_IF_FALSE(InImageBridgeChildThread(),
                    "Should be in ImageBridgeChild thread.");

  ClearSharedImagePool();

  Send__delete__(this);
}
bool
RemotePrintJobParent::RecvAbortPrint(const nsresult& aRv)
{
  if (mPrintDeviceContext) {
    Unused << mPrintDeviceContext->AbortDocument();
  }

  Unused << Send__delete__(this);
  return true;
}
mozilla::ipc::IPCResult
WebRenderBridgeParent::HandleShutdown()
{
  Destroy();
  IProtocol* mgr = Manager();
  if (!Send__delete__(this)) {
    return IPC_FAIL_NO_REASON(mgr);
  }
  return IPC_OK();
}
bool
GMPVideoEncoderChild::RecvEncodingComplete()
{
  if (!mVideoEncoder) {
    unused << Send__delete__(this);
    return false;
  }

  // Ignore any return code. It is OK for this to fail without killing the process.
  mVideoEncoder->EncodingComplete();

  mVideoHost.DoneWithAPI();

  mPlugin = nullptr;

  unused << Send__delete__(this);

  return true;
}
mozilla::ipc::IPCResult
TemporaryIPCBlobParent::RecvOperationFailed()
{
  MOZ_ASSERT(mActive);
  mActive = false;

  // Nothing to do.
  Unused << Send__delete__(this, NS_ERROR_FAILURE);
  return IPC_OK();
}
NS_IMETHODIMP
PSMContentDownloaderParent::OnStopRequest(nsIRequest* request, nsISupports* context, nsresult code)
{
  nsresult rv = PSMContentStreamListener::OnStopRequest(request, context, code);

  if (mIPCOpen) {
    mozilla::unused << Send__delete__(this);
  }
  return rv;
}
Exemple #28
0
nsresult
SmsRequestParent::SendReply(const MessageReply& aReply)
{
  // The child process could die before this asynchronous notification, in which
  // case ActorDestroy() was called and mActorDestroyed is set to true. Return
  // an error here to avoid sending a message to the dead process.
  NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE);

  return Send__delete__(this, aReply) ? NS_OK : NS_ERROR_FAILURE;
}
bool
BluetoothChild::RecvNotificationsStopped()
{
  if (mShutdownState != SentStopNotifying) {
    MOZ_ASSERT(false, "Bad state!");
    return false;
  }

  Send__delete__(this);
  return true;
}
NS_IMETHODIMP
WebBrowserPersistSerializeChild::OnFinish(nsIWebBrowserPersistDocument* aDocument,
                                          nsIOutputStream* aStream,
                                          const nsACString& aContentType,
                                          nsresult aStatus)
{
    MOZ_ASSERT(aStream == this);
    nsCString contentType(aContentType);
    Send__delete__(this, contentType, aStatus);
    return NS_OK;
}