예제 #1
0
void
FilePickerParent::SendFiles(const nsCOMArray<nsIDOMFile>& aDomfiles)
{
  ContentParent* parent = static_cast<ContentParent*>(Manager()->Manager());
  InfallibleTArray<PBlobParent*> files;

  for (unsigned i = 0; i < aDomfiles.Length(); i++) {
    BlobParent* blob = parent->GetOrCreateActorForBlob(aDomfiles[i]);
    if (blob) {
      files.AppendElement(blob);
    }
  }

  InputFiles infiles;
  infiles.filesParent().SwapElements(files);
  unused << Send__delete__(this, infiles, mResult);
}
FileSystemResponseValue
GetFileOrDirectoryTask::GetSuccessRequestResult() const
{
  MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
  if (mIsDirectory) {
    return FileSystemDirectoryResponse(mTargetRealPath);
  }

  ContentParent* cp = static_cast<ContentParent*>(mRequestParent->Manager());
  BlobParent* actor = cp->GetOrCreateActorForBlob(mTargetFile);
  if (!actor) {
    return FileSystemErrorResponse(NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR);
  }
  FileSystemFileResponse response;
  response.blobParent() = actor;
  return response;
}
nsresult
DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() {
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  nsString mime;
  CopyASCIItoUTF16(mMimeType, mime);

  nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(mFile->mPath, mime, mLength, mFile->mFile);

  ContentParent* cp = static_cast<ContentParent*>(mParent->Manager());
  BlobParent* actor = cp->GetOrCreateActorForBlob(blob);

  BlobResponse response;
  response.blobParent() = actor;

  unused <<  mParent->Send__delete__(mParent, response);
  return NS_OK;
}