コード例 #1
0
void
GetDirectoryListingTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                      ErrorResult& aRv)
{
  mFileSystem->AssertIsOnOwningThread();
  MOZ_ASSERT(aValue.type() ==
               FileSystemResponseValue::TFileSystemDirectoryListingResponse);

  FileSystemDirectoryListingResponse r = aValue;
  for (uint32_t i = 0; i < r.data().Length(); ++i) {
    const FileSystemDirectoryListingResponseData& data = r.data()[i];

    Directory::FileOrDirectoryPath element;

    if (data.type() == FileSystemDirectoryListingResponseData::TFileSystemDirectoryListingResponseFile) {
      element.mType = Directory::FileOrDirectoryPath::eFilePath;
      element.mPath = data.get_FileSystemDirectoryListingResponseFile().fileRealPath();
    } else {
      MOZ_ASSERT(data.type() == FileSystemDirectoryListingResponseData::TFileSystemDirectoryListingResponseDirectory);

      element.mType = Directory::FileOrDirectoryPath::eDirectoryPath;
      element.mPath = data.get_FileSystemDirectoryListingResponseDirectory().directoryRealPath();
    }

    if (!mTargetData.AppendElement(element, fallible)) {
      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
      return;
    }
  }
}
コード例 #2
0
void
GetFileOrDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                     ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
  switch (aValue.type()) {
    case FileSystemResponseValue::TFileSystemFileResponse: {
      FileSystemFileResponse r = aValue;

      aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
      if (NS_WARN_IF(aRv.Failed())) {
        return;
      }

      mIsDirectory = false;
      break;
    }
    case FileSystemResponseValue::TFileSystemDirectoryResponse: {
      FileSystemDirectoryResponse r = aValue;

      aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(mTargetPath));
      if (NS_WARN_IF(aRv.Failed())) {
        return;
      }

      mIsDirectory = true;
      break;
    }
    default: {
      MOZ_CRASH("not reached");
      break;
    }
  }
}
コード例 #3
0
void
GetFileOrDirectoryTask::SetSuccessRequestResult(const FileSystemResponseValue& aValue)
{
    MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
    switch (aValue.type()) {
    case FileSystemResponseValue::TFileSystemFileResponse: {
        FileSystemFileResponse r = aValue;
        BlobChild* actor = static_cast<BlobChild*>(r.blobChild());
        nsCOMPtr<nsIDOMBlob> blob = actor->GetBlob();
        mTargetFile = do_QueryInterface(blob);
        mIsDirectory = false;
        break;
    }
    case FileSystemResponseValue::TFileSystemDirectoryResponse: {
        FileSystemDirectoryResponse r = aValue;
        mTargetRealPath = r.realPath();
        mIsDirectory = true;
        break;
    }
    default: {
        NS_RUNTIMEABORT("not reached");
        break;
    }
    }
}
コード例 #4
0
void
FileSystemTaskBase::SetRequestResult(const FileSystemResponseValue& aValue)
{
  MOZ_ASSERT(!FileSystemUtils::IsParentProcess(),
             "Only call from child process!");
  MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
  if (aValue.type() == FileSystemResponseValue::TFileSystemErrorResponse) {
    FileSystemErrorResponse r = aValue;
    mErrorValue = r.error();
  } else {
    SetSuccessRequestResult(aValue);
  }
}
コード例 #5
0
void
GetDirectoryListingTask::SetSuccessRequestResult(const FileSystemResponseValue& aValue)
{
  MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
  MOZ_ASSERT(aValue.type() ==
               FileSystemResponseValue::TFileSystemDirectoryListingResponse);

  FileSystemDirectoryListingResponse r = aValue;
  nsTArray<PBlobChild*>& blobs = r.blobsChild();

  for (unsigned i = 0; i < blobs.Length(); i++) {
    mTargetBlobImpls.AppendElement(static_cast<BlobChild*>(blobs[i])->GetBlobImpl());
  }
}
コード例 #6
0
void
FileSystemTaskChildBase::SetRequestResult(const FileSystemResponseValue& aValue)
{
  mFileSystem->AssertIsOnOwningThread();

  if (aValue.type() == FileSystemResponseValue::TFileSystemErrorResponse) {
    FileSystemErrorResponse r = aValue;
    mErrorValue = r.error();
  } else {
    ErrorResult rv;
    SetSuccessRequestResult(aValue, rv);
    mErrorValue = rv.StealNSResult();
  }
}
コード例 #7
0
void
GetDirectoryListingTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                      ErrorResult& aRv)
{
  mFileSystem->AssertIsOnOwningThread();
  MOZ_ASSERT(aValue.type() ==
               FileSystemResponseValue::TFileSystemDirectoryListingResponse);

  FileSystemDirectoryListingResponse r = aValue;
  for (uint32_t i = 0; i < r.data().Length(); ++i) {
    const FileSystemDirectoryListingResponseData& data = r.data()[i];

    OwningFileOrDirectory* ofd = mTargetData.AppendElement(fallible);
    if (!ofd) {
      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
      return;
    }

    if (data.type() == FileSystemDirectoryListingResponseData::TFileSystemDirectoryListingResponseFile) {
      const FileSystemDirectoryListingResponseFile& d =
        data.get_FileSystemDirectoryListingResponseFile();

      RefPtr<BlobImpl> blobImpl =
        static_cast<BlobChild*>(d.blobChild())->GetBlobImpl();
      MOZ_ASSERT(blobImpl);

      RefPtr<File> file = File::Create(mFileSystem->GetParentObject(), blobImpl);
      MOZ_ASSERT(file);

      ofd->SetAsFile() = file;
    } else {
      MOZ_ASSERT(data.type() == FileSystemDirectoryListingResponseData::TFileSystemDirectoryListingResponseDirectory);
      const FileSystemDirectoryListingResponseDirectory& d =
        data.get_FileSystemDirectoryListingResponseDirectory();

      nsCOMPtr<nsIFile> path;
      aRv = NS_NewLocalFile(d.directoryRealPath(), true, getter_AddRefs(path));
      if (NS_WARN_IF(aRv.Failed())) {
        return;
      }

      RefPtr<Directory> directory =
        Directory::Create(mFileSystem->GetParentObject(), path, mFileSystem);
      MOZ_ASSERT(directory);

      ofd->SetAsDirectory() = directory;
    }
  }
}
コード例 #8
0
void
GetFileOrDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                     ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
  switch (aValue.type()) {
    case FileSystemResponseValue::TFileSystemFileResponse: {
      FileSystemFileResponse r = aValue;

      RefPtr<BlobImpl> blobImpl =
        static_cast<BlobChild*>(r.blobChild())->GetBlobImpl();
      MOZ_ASSERT(blobImpl);

      mResultFile = File::Create(mFileSystem->GetParentObject(), blobImpl);
      MOZ_ASSERT(mResultFile);
      break;
    }
    case FileSystemResponseValue::TFileSystemDirectoryResponse: {
      FileSystemDirectoryResponse r = aValue;

      nsCOMPtr<nsIFile> file;
      aRv = NS_NewLocalFile(r.realPath(), true, getter_AddRefs(file));
      if (NS_WARN_IF(aRv.Failed())) {
        return;
      }

      mResultDirectory = Directory::Create(mFileSystem->GetParentObject(),
                                           file, mFileSystem);
      MOZ_ASSERT(mResultDirectory);
      break;
    }
    default: {
      MOZ_CRASH("not reached");
      break;
    }
  }
}
コード例 #9
0
void
GetFilesTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                           ErrorResult& aRv)
{
  mFileSystem->AssertIsOnOwningThread();
  MOZ_ASSERT(aValue.type() ==
               FileSystemResponseValue::TFileSystemFilesResponse);

  FileSystemFilesResponse r = aValue;

  if (!mTargetData.SetLength(r.data().Length(), mozilla::fallible_t())) {
    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
    return;
  }

  for (uint32_t i = 0; i < r.data().Length(); ++i) {
    const FileSystemFileResponse& data = r.data()[i];
    RefPtr<BlobImpl> blobImpl =
      static_cast<BlobChild*>(data.blobChild())->GetBlobImpl();
    MOZ_ASSERT(blobImpl);

    mTargetData[i] = File::Create(mFileSystem->GetParentObject(), blobImpl);
  }
}