/* static */
already_AddRefed<FileDescriptorOutputStream> FileDescriptorOutputStream::Create(
    const ipc::FileDescriptor& fileDescriptor) {
  if (NS_WARN_IF(!fileDescriptor.IsValid())) return nullptr;

  auto rawFD = fileDescriptor.ClonePlatformHandle();
  PRFileDesc* prfd = PR_ImportFile(PROsfd(rawFD.release()));
  if (NS_WARN_IF(!prfd)) return nullptr;

  RefPtr<FileDescriptorOutputStream> stream =
      new FileDescriptorOutputStream(prfd);
  return stream.forget();
}
/* static */ already_AddRefed<FileDescriptorOutputStream>
FileDescriptorOutputStream::Create(const ipc::FileDescriptor& fileDescriptor)
{
  if (NS_WARN_IF(!fileDescriptor.IsValid()))
    return nullptr;

  PRFileDesc* prfd = PR_ImportFile(PROsfd(fileDescriptor.PlatformHandle()));
  if (NS_WARN_IF(!prfd))
    return nullptr;

  nsRefPtr<FileDescriptorOutputStream> stream = new FileDescriptorOutputStream(prfd);
  return stream.forget();
}