Bug 1173320 - patch 6/8 - Make FileList clonable to workers if it doesn't contain Directories, r=smaug

This commit is contained in:
Andrea Marchesini 2016-03-20 11:56:10 +01:00
parent 69278a33e5
commit 5f7cc5cffa
4 changed files with 19 additions and 4 deletions

View File

@ -111,5 +111,17 @@ FileList::ToSequence(Sequence<OwningFileOrDirectory>& aSequence,
}
}
bool
FileList::ClonableToDifferentThreadOrProcess() const
{
for (uint32_t i = 0; i < mFilesOrDirectories.Length(); ++i) {
if (mFilesOrDirectories[i].IsDirectory()) {
return false;
}
}
return true;
}
} // namespace dom
} // namespace mozilla

View File

@ -97,6 +97,8 @@ public:
void ToSequence(Sequence<OwningFileOrDirectory>& aSequence,
ErrorResult& aRv) const;
bool ClonableToDifferentThreadOrProcess() const;
private:
~FileList() {}

View File

@ -1008,7 +1008,6 @@ StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
}
if (aTag == SCTAG_DOM_FILELIST) {
MOZ_ASSERT(mSupportedContext == SameProcessSameThread);
return ReadFileList(aCx, aReader, aIndex, this);
}
@ -1049,9 +1048,11 @@ StructuredCloneHolder::CustomWriteHandler(JSContext* aCx,
}
// See if this is a FileList object.
if (mSupportedContext == SameProcessSameThread) {
{
FileList* fileList = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(FileList, aObj, fileList))) {
if (NS_SUCCEEDED(UNWRAP_OBJECT(FileList, aObj, fileList)) &&
(mSupportedContext == SameProcessSameThread ||
fileList->ClonableToDifferentThreadOrProcess())) {
return WriteFileList(aWriter, fileList, this);
}
}

View File

@ -84,7 +84,7 @@ function create_fileList() {
var domFile = fileList.files[0];
is(domFile.name, "prefs.js", "fileName should be prefs.js");
clonableObjects.push({ crossThreads: false, data: fileList.files });
clonableObjects.push({ crossThreads: true, data: fileList.files });
script.destroy();
next();
}