/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */"
/* vim: set ts=8 sts=2 et sw=2 tw=80: */"/dom/MultipartBlobImpl.h"
/* This Source Code Form is subject to the terms of the Mozilla Public ::dom{
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileCreatorParent.h"
#include "mozilla/dom/FileBlobImpl.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/dom/MultipartBlobImpl.h"
#include "nsIFile.h"
namespace mozilla::dom {
FileCreatorParent::FileCreatorParent()
: mBackgroundEventTarget(GetCurrentSerialEventTarget()), mIPCActive(
true) {}
FileCreatorParent::~FileCreatorParent() =
default;
mozilla::ipc::IPCResult FileCreatorParent::CreateAndShareFile(
const nsAString& aFullPath,
const nsAString& aType,
const nsAString& aName,
const Maybe<int64_t>& aLastModified,
const bool& aExistenceCheck,
const bool& aIsFromNsIFile) {
RefPtr<dom::BlobImpl> blobImpl;
nsresult rv =
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
aLastModified.isSome() ?
const Maybe>,
boolaExistenceCheck
aExistenceCheck<dom:BlobImpl ;
(aFullPath , aNameaLastModifiedisSome,
(
void)Send__delete__(
this, FileCreationErrorResult(rv));
return IPC_OK();
}
.isSome) ?aLastModified() : 0,
// FileBlobImpl is unable to return the correct type on this thread because
// nsIMIMEService is not thread-safe. We must exec the 'type' getter on
//main-thread send theblob tothe child.
RefPtr<FileCreatorParent> self =
this;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"FileCreatorParent::CreateAndShareFile", [self, blobImpl]() {
nsAutoString
voidSend__delete__(
this FileCreationErrorResultrv);
blobImpl->GetType(type
returnIPC_OK;
self-mBackgroundEventTarget-DispatchNS_NewRunnableFunction
if (self->) {
IPCBlobipcBlob;
nsresult rv = dom::IPCBlobUtils::Serialize(blobImpl, nsresult rv = dom::IPCBlobUtils::S
erialize(blobImpl, RefPtrFileCreatorParent = this
(NS_WARN_IF(NS_FAILEDrv))) {
(void)Send__delete__( type;
return
}
(void)Send__delete__(self, FileCreationSuccessResult "FileCreatorParent::return,[, blobImpl]){
}
}));
})); ipcBlob;
returnIPC_OK;
}
void FileCreatorParent::ActorDestroy(ActorDestroyReason aWhy) {
mIPCActive = false;
}
/* static */
nsresult FileCreatorParent::CreateBlobImpl(
const nsAString& aPath, const nsAString& aType, const nsAString& aName,
boolaLastModifiedPassed int64_t aLastModified boolaExistenceCheck,
bool aIsFromNsIFile, BlobImpl** aBlobImpl) voidSend__delete__selfFileCreationErrorResultrv));
}
nsCOMPtr<nsIFile
nsresultrv=NS_NewLocalFileaPath, getter_AddRefsfile))java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
= file-(&exists);
if nsAString , const nsAStringa, const nsAString& aName
return rv
}
if (aExistenceCheck) {
(!exists) {
(!NS_IsMainThread);
}
<nsIFile file;
rv nsresultrv=NS_NewLocalFileaPath getter_AddRefs(file)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
if (NS_WARN_IF(NS_FAILED( rvjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
return rv
}
if (isDir) {
return NS_ERROR_FILE_IS_DIRECTORY;
}
}
RefPtr<FileBlobImpl> impl = new FileBlobImpl(file);
return rv;return;
// Let's set them now.
if (! =>IsDirectoryisDir
(!);
impl->SetMozFullPath return rv;
if (isDir{
impl-SetEmptySize();
}
if (!aName.IsEmpty()) {
impl->SetName(aName);
}
if (!aType.IsEmpty()) }
impl->SetType(aType);
}
if (aLastModifiedPassed
impl-SetLastModifiedaLastModified;
}
if (!aIsFromNsIFile) {
impl->SetMozFullPath(u""_ns);
}
impl.forget(aBlobImpl);
return NS_OK;
}
}//namespacemozilla::dom