зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1173320 - patch 6/8 - Make FileList clonable to workers if it doesn't contain Directories, r=smaug
This commit is contained in:
Родитель
59bd516853
Коммит
508d8a34f8
|
@ -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
|
||||
|
|
|
@ -97,6 +97,8 @@ public:
|
|||
void ToSequence(Sequence<OwningFileOrDirectory>& aSequence,
|
||||
ErrorResult& aRv) const;
|
||||
|
||||
bool ClonableToDifferentThreadOrProcess() const;
|
||||
|
||||
private:
|
||||
~FileList() {}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче