Bug 1542931 serialize AudioWorkletNodeOptions r=padenot

Depends on D34478

Differential Revision: https://phabricator.services.mozilla.com/D34479

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Karl Tomlinson 2019-06-14 13:23:57 +00:00
parent 53e03975c9
commit 4891262c8d

View File

@ -80,6 +80,27 @@ already_AddRefed<AudioWorkletNode> AudioWorkletNode::Constructor(
return nullptr;
}
/**
* 7. Let optionsSerialization be the result of StructuredSerialize(options).
*/
JSContext* cx = aGlobal.Context();
JS::Rooted<JS::Value> optionsVal(cx);
if (NS_WARN_IF(!ToJSValue(cx, aOptions, &optionsVal))) {
aRv.NoteJSContextException(cx);
return nullptr;
}
// StructuredCloneHolder does not have a move constructor. Instead allocate
// memory so that the pointer can be passed to the rendering thread.
UniquePtr<StructuredCloneHolder> optionsSerialization =
MakeUnique<StructuredCloneHolder>(
StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringNotSupported,
JS::StructuredCloneScope::SameProcessDifferentThread);
optionsSerialization->Write(cx, optionsVal, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
return audioWorkletNode.forget();
}