/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. */
if (aTargetGlobal) { // OK to unwrap if our caller (represented by cx's Realm) can do it.
JS::Rooted<JSObject*> targetGlobal(
cx, js::CheckedUnwrapDynamic(aTargetGlobal, cx)); if (!targetGlobal) {
js::ReportAccessDenied(cx);
aRv.NoteJSContextException(cx); return nullptr;
}
ar.emplace(cx, targetGlobal);
if (!JS_WrapValue(cx, &value)) {
aRv.NoteJSContextException(cx); return nullptr;
}
} elseif (value.isObject()) { // OK to unwrap if our caller (represented by cx's Realm) can do it.
JS::Rooted<JSObject*> obj(cx,
js::CheckedUnwrapDynamic(&value.toObject(), cx)); if (!obj) {
js::ReportAccessDenied(cx);
aRv.NoteJSContextException(cx); return nullptr;
}
ar.emplace(cx, obj);
value = JS::ObjectValue(*obj);
}
holder->mHolder->Write(cx, value, aRv); if (aRv.Failed()) { return nullptr;
}
return holder.forget();
}
void StructuredCloneBlob::Deserialize(JSContext* aCx,
JS::Handle<JSObject*> aTargetScope, bool aKeepData,
JS::MutableHandle<JS::Value> aResult,
ErrorResult& aRv) { // OK to unwrap if our caller (represented by aCx's Realm) can do it.
JS::Rooted<JSObject*> scope(aCx, js::CheckedUnwrapDynamic(aTargetScope, aCx)); if (!scope) {
js::ReportAccessDenied(aCx);
aRv.NoteJSContextException(aCx); return;
}
if (!mHolder.isSome()) {
aRv.Throw(NS_ERROR_NOT_INITIALIZED); return;
}
{
JSAutoRealm ar(aCx, scope);
mHolder->Read(xpc::NativeGlobal(scope), aCx, aResult, aRv); if (aRv.Failed()) { return;
}
}
if (!aKeepData) {
mHolder.reset();
}
if (!JS_WrapValue(aCx, aResult)) {
aResult.set(JS::UndefinedValue());
aRv.NoteJSContextException(aCx);
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.