From 6d6aa4cc6680a1c36497ae8707eac0e3808f5932 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 15 Jan 2020 09:59:16 +0000 Subject: [PATCH] Bug 1607791 - Get rid of IDBMutableFile.getFile() - part 3 - Rename SameProcessDifferentThread to SameProcess, r=asuth,sfink Differential Revision: https://phabricator.services.mozilla.com/D59142 --HG-- extra : moz-landing-system : lando --- dom/base/PostMessageEvent.h | 2 +- dom/base/SerializedStackHolder.cpp | 3 +- dom/base/StructuredCloneHolder.cpp | 43 +++++++------------ dom/base/StructuredCloneHolder.h | 3 +- dom/media/webaudio/AudioWorkletNode.cpp | 2 +- dom/workers/MessageEventRunnable.cpp | 2 +- dom/xhr/XMLHttpRequestWorker.cpp | 2 +- js/public/StructuredClone.h | 6 +-- js/src/builtin/TestingFunctions.cpp | 15 +++---- js/src/jsapi-tests/testMappedArrayBuffer.cpp | 4 +- js/src/jsapi-tests/testStructuredClone.cpp | 3 +- .../tests/non262/extensions/clone-errors.js | 4 +- .../non262/extensions/clone-transferables.js | 2 +- js/src/vm/StructuredClone.cpp | 12 +++--- 14 files changed, 43 insertions(+), 60 deletions(-) diff --git a/dom/base/PostMessageEvent.h b/dom/base/PostMessageEvent.h index 6c9c2ff3cc65..2978178f1b64 100644 --- a/dom/base/PostMessageEvent.h +++ b/dom/base/PostMessageEvent.h @@ -60,7 +60,7 @@ class PostMessageEvent final : public Runnable { mHolder.construct( StructuredCloneHolder::CloningSupported, StructuredCloneHolder::TransferringSupported, - JS::StructuredCloneScope::SameProcessDifferentThread); + JS::StructuredCloneScope::SameProcess); mHolder.ref().Write(aCx, aMessage, aTransfer, aClonePolicy, aError); } diff --git a/dom/base/SerializedStackHolder.cpp b/dom/base/SerializedStackHolder.cpp index 142bcdab4316..26003d01c2c0 100644 --- a/dom/base/SerializedStackHolder.cpp +++ b/dom/base/SerializedStackHolder.cpp @@ -15,8 +15,7 @@ namespace dom { SerializedStackHolder::SerializedStackHolder() : mHolder(StructuredCloneHolder::CloningSupported, StructuredCloneHolder::TransferringNotSupported, - StructuredCloneHolder::StructuredCloneScope:: - SameProcessDifferentThread) {} + StructuredCloneHolder::StructuredCloneScope::SameProcess) {} void SerializedStackHolder::WriteStack(JSContext* aCx, JS::HandleObject aStack) { diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp index fccb46db8c3d..5a07697ac222 100644 --- a/dom/base/StructuredCloneHolder.cpp +++ b/dom/base/StructuredCloneHolder.cpp @@ -789,9 +789,8 @@ bool WriteFormData(JSStructuredCloneWriter* aWriter, FormData* aFormData, JSObject* ReadWasmModule(JSContext* aCx, uint32_t aIndex, StructuredCloneHolder* aHolder) { MOZ_ASSERT(aHolder); - MOZ_ASSERT( - aHolder->CloneScope() == - StructuredCloneHolder::StructuredCloneScope::SameProcessDifferentThread); + MOZ_ASSERT(aHolder->CloneScope() == + StructuredCloneHolder::StructuredCloneScope::SameProcess); #ifdef FUZZING if (aIndex >= aHolder->WasmModules().Length()) { return nullptr; @@ -808,9 +807,8 @@ bool WriteWasmModule(JSStructuredCloneWriter* aWriter, MOZ_ASSERT(aWriter); MOZ_ASSERT(aWasmModule); MOZ_ASSERT(aHolder); - MOZ_ASSERT( - aHolder->CloneScope() == - StructuredCloneHolder::StructuredCloneScope::SameProcessDifferentThread); + MOZ_ASSERT(aHolder->CloneScope() == + StructuredCloneHolder::StructuredCloneScope::SameProcess); // We store the position of the wasmModule in the array as index. if (JS_WriteUint32Pair(aWriter, SCTAG_DOM_WASM, @@ -886,8 +884,7 @@ JSObject* StructuredCloneHolder::CustomReadHandler( } if (aTag == SCTAG_DOM_IMAGEBITMAP && - mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + mStructuredCloneScope == StructuredCloneScope::SameProcess) { // Get the current global object. // This can be null. JS::RootedObject result(aCx); @@ -904,8 +901,7 @@ JSObject* StructuredCloneHolder::CustomReadHandler( } if (aTag == SCTAG_DOM_WASM && - mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + mStructuredCloneScope == StructuredCloneScope::SameProcess) { return ReadWasmModule(aCx, aIndex, this); } @@ -966,8 +962,7 @@ bool StructuredCloneHolder::CustomWriteHandler(JSContext* aCx, } // See if this is an ImageBitmap object. - if (mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + if (mStructuredCloneScope == StructuredCloneScope::SameProcess) { ImageBitmap* imageBitmap = nullptr; if (NS_SUCCEEDED(UNWRAP_OBJECT(ImageBitmap, &obj, imageBitmap))) { return ImageBitmap::WriteStructuredClone(aWriter, GetSurfaces(), @@ -984,8 +979,7 @@ bool StructuredCloneHolder::CustomWriteHandler(JSContext* aCx, } // See if this is a BrowsingContext object. - if (mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread || + if (mStructuredCloneScope == StructuredCloneScope::SameProcess || mStructuredCloneScope == StructuredCloneScope::DifferentProcess) { BrowsingContext* holder = nullptr; if (NS_SUCCEEDED(UNWRAP_OBJECT(BrowsingContext, &obj, holder))) { @@ -1002,8 +996,7 @@ bool StructuredCloneHolder::CustomWriteHandler(JSContext* aCx, } // See if this is a WasmModule. - if (mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread && + if (mStructuredCloneScope == StructuredCloneScope::SameProcess && JS::IsWasmModuleObject(obj)) { RefPtr module = JS::GetWasmModule(obj); MOZ_ASSERT(module); @@ -1058,8 +1051,7 @@ bool StructuredCloneHolder::CustomReadTransferHandler( } if (aTag == SCTAG_DOM_CANVAS && - mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + mStructuredCloneScope == StructuredCloneScope::SameProcess) { MOZ_ASSERT(aContent); OffscreenCanvasCloneData* data = static_cast(aContent); @@ -1078,8 +1070,7 @@ bool StructuredCloneHolder::CustomReadTransferHandler( } if (aTag == SCTAG_DOM_IMAGEBITMAP && - mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + mStructuredCloneScope == StructuredCloneScope::SameProcess) { MOZ_ASSERT(aContent); ImageBitmapCloneData* data = static_cast(aContent); RefPtr bitmap = @@ -1131,8 +1122,7 @@ bool StructuredCloneHolder::CustomWriteTransferHandler( return true; } - if (mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + if (mStructuredCloneScope == StructuredCloneScope::SameProcess) { OffscreenCanvas* canvas = nullptr; rv = UNWRAP_OBJECT(OffscreenCanvas, &obj, canvas); if (NS_SUCCEEDED(rv)) { @@ -1196,8 +1186,7 @@ void StructuredCloneHolder::CustomFreeTransferHandler( } if (aTag == SCTAG_DOM_CANVAS && - mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + mStructuredCloneScope == StructuredCloneScope::SameProcess) { MOZ_ASSERT(aContent); OffscreenCanvasCloneData* data = static_cast(aContent); @@ -1206,8 +1195,7 @@ void StructuredCloneHolder::CustomFreeTransferHandler( } if (aTag == SCTAG_DOM_IMAGEBITMAP && - mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + mStructuredCloneScope == StructuredCloneScope::SameProcess) { MOZ_ASSERT(aContent); ImageBitmapCloneData* data = static_cast(aContent); delete data; @@ -1230,8 +1218,7 @@ bool StructuredCloneHolder::CustomCanTransferHandler( return true; } - if (mStructuredCloneScope == - StructuredCloneScope::SameProcessDifferentThread) { + if (mStructuredCloneScope == StructuredCloneScope::SameProcess) { OffscreenCanvas* canvas = nullptr; rv = UNWRAP_OBJECT(OffscreenCanvas, &obj, canvas); if (NS_SUCCEEDED(rv)) { diff --git a/dom/base/StructuredCloneHolder.h b/dom/base/StructuredCloneHolder.h index 8e5daf4e7172..8049c6b476fb 100644 --- a/dom/base/StructuredCloneHolder.h +++ b/dom/base/StructuredCloneHolder.h @@ -39,8 +39,7 @@ class StructuredCloneHolderBase { typedef JS::StructuredCloneScope StructuredCloneScope; StructuredCloneHolderBase( - StructuredCloneScope aScope = - StructuredCloneScope::SameProcessDifferentThread); + StructuredCloneScope aScope = StructuredCloneScope::SameProcess); virtual ~StructuredCloneHolderBase(); // Note, it is unsafe to std::move() a StructuredCloneHolderBase since a raw diff --git a/dom/media/webaudio/AudioWorkletNode.cpp b/dom/media/webaudio/AudioWorkletNode.cpp index 0b49e8e58401..b80b8ac6b759 100644 --- a/dom/media/webaudio/AudioWorkletNode.cpp +++ b/dom/media/webaudio/AudioWorkletNode.cpp @@ -520,7 +520,7 @@ already_AddRefed AudioWorkletNode::Constructor( MakeUnique( StructuredCloneHolder::CloningSupported, StructuredCloneHolder::TransferringNotSupported, - JS::StructuredCloneScope::SameProcessDifferentThread); + JS::StructuredCloneScope::SameProcess); serializedOptions->Write(cx, optionsVal, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; diff --git a/dom/workers/MessageEventRunnable.cpp b/dom/workers/MessageEventRunnable.cpp index 6f763f3fab65..c23ae9ad3393 100644 --- a/dom/workers/MessageEventRunnable.cpp +++ b/dom/workers/MessageEventRunnable.cpp @@ -21,7 +21,7 @@ MessageEventRunnable::MessageEventRunnable(WorkerPrivate* aWorkerPrivate, TargetAndBusyBehavior aBehavior) : WorkerDebuggeeRunnable(aWorkerPrivate, aBehavior), StructuredCloneHolder(CloningSupported, TransferringSupported, - StructuredCloneScope::SameProcessDifferentThread) {} + StructuredCloneScope::SameProcess) {} bool MessageEventRunnable::DispatchDOMEvent(JSContext* aCx, WorkerPrivate* aWorkerPrivate, diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp index 9c4415ffb667..a17856a15dc0 100644 --- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -237,7 +237,7 @@ class SendRunnable final : public WorkerThreadProxySyncRunnable, const nsAString& aStringBody) : WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy), StructuredCloneHolder(CloningSupported, TransferringNotSupported, - StructuredCloneScope::SameProcessDifferentThread), + StructuredCloneScope::SameProcess), mStringBody(aStringBody), mHasUploadListeners(false) {} diff --git a/js/public/StructuredClone.h b/js/public/StructuredClone.h index a0ac6df8758b..2330d2b3d175 100644 --- a/js/public/StructuredClone.h +++ b/js/public/StructuredClone.h @@ -137,7 +137,7 @@ enum class StructuredCloneScope : uint32_t { * as part of the SCTAG_HEADER, and IndexedDB persists the representation to * disk. */ - SameProcessDifferentThread = 1, + SameProcess = 1, /** * When writing, this means we're writing for an audience in a different @@ -156,8 +156,8 @@ enum class StructuredCloneScope : uint32_t { /** * Handle a backwards-compatibility case with IndexedDB (bug 1434308): when - * reading, this means to treat legacy SameProcessDifferentThread data as if - * it were DifferentProcess. + * reading, this means to treat legacy SameProcess data as if it were + * DifferentProcess. * * Do not use this for writing; use DifferentProcess instead. */ diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 8692363cb5d2..af65635d7423 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -3381,8 +3381,8 @@ static mozilla::Maybe ParseCloneScope( return scope; } - if (StringEqualsLiteral(scopeStr, "SameProcessDifferentThread")) { - scope.emplace(JS::StructuredCloneScope::SameProcessDifferentThread); + if (StringEqualsLiteral(scopeStr, "SameProcess")) { + scope.emplace(JS::StructuredCloneScope::SameProcess); } else if (StringEqualsLiteral(scopeStr, "DifferentProcess")) { scope.emplace(JS::StructuredCloneScope::DifferentProcess); } else if (StringEqualsLiteral(scopeStr, "DifferentProcessForIndexedDB")) { @@ -3448,8 +3448,7 @@ bool js::testingFunc_serialize(JSContext* cx, unsigned argc, Value* vp) { } if (!clonebuf) { - clonebuf.emplace(JS::StructuredCloneScope::SameProcessDifferentThread, - nullptr, nullptr); + clonebuf.emplace(JS::StructuredCloneScope::SameProcess, nullptr, nullptr); } if (!clonebuf->write(cx, args.get(0), args.get(1), policy)) { @@ -3478,7 +3477,7 @@ static bool Deserialize(JSContext* cx, unsigned argc, Value* vp) { JS::CloneDataPolicy policy; JS::StructuredCloneScope scope = obj->isSynthetic() ? JS::StructuredCloneScope::DifferentProcess - : JS::StructuredCloneScope::SameProcessDifferentThread; + : JS::StructuredCloneScope::SameProcess; if (args.get(1).isObject()) { RootedObject opts(cx, &args[1].toObject()); if (!opts) { @@ -6743,7 +6742,7 @@ gc::ZealModeHelpText), " clone buffer object. 'policy' may be an options hash. Valid keys:\n" " 'SharedArrayBuffer' - either 'allow' or 'deny' (the default)\n" " to specify whether SharedArrayBuffers may be serialized.\n" -" 'scope' - SameProcessDifferentThread, DifferentProcess, or\n" +" 'scope' - SameProcess, DifferentProcess, or\n" " DifferentProcessForIndexedDB. Determines how some values will be\n" " serialized. Clone buffers may only be deserialized with a compatible\n" " scope. NOTE - For DifferentProcess/DifferentProcessForIndexedDB,\n" @@ -6757,10 +6756,10 @@ gc::ZealModeHelpText), " 'SharedArrayBuffer' - either 'allow' or 'deny' (the default)\n" " to specify whether SharedArrayBuffers may be serialized.\n" " 'scope', which limits the clone buffers that are considered\n" -" valid. Allowed values: ''SameProcessDifferentThread', 'DifferentProcess',\n" +" valid. Allowed values: ''SameProcess', 'DifferentProcess',\n" " and 'DifferentProcessForIndexedDB'. So for example, a\n" " DifferentProcessForIndexedDB clone buffer may be deserialized in any scope, but\n" -" a SameProcessDifferentThread clone buffer cannot be deserialized in a\n" +" a SameProcess clone buffer cannot be deserialized in a\n" " DifferentProcess scope."), JS_FN_HELP("detachArrayBuffer", DetachArrayBuffer, 1, 0, diff --git a/js/src/jsapi-tests/testMappedArrayBuffer.cpp b/js/src/jsapi-tests/testMappedArrayBuffer.cpp index 297021853afa..4950384156db 100644 --- a/js/src/jsapi-tests/testMappedArrayBuffer.cpp +++ b/js/src/jsapi-tests/testMappedArrayBuffer.cpp @@ -134,7 +134,7 @@ bool TestCloneObject() { JS::RootedObject obj1(cx, CreateNewObject(8, 12)); CHECK(obj1); JSAutoStructuredCloneBuffer cloned_buffer( - JS::StructuredCloneScope::SameProcessDifferentThread, nullptr, nullptr); + JS::StructuredCloneScope::SameProcess, nullptr, nullptr); JS::RootedValue v1(cx, JS::ObjectValue(*obj1)); CHECK(cloned_buffer.write(cx, v1, nullptr, nullptr)); JS::RootedValue v2(cx); @@ -173,7 +173,7 @@ bool TestTransferObject() { JS::RootedValue transferable(cx, JS::ObjectValue(*obj)); JSAutoStructuredCloneBuffer cloned_buffer( - JS::StructuredCloneScope::SameProcessDifferentThread, nullptr, nullptr); + JS::StructuredCloneScope::SameProcess, nullptr, nullptr); JS::CloneDataPolicy policy; CHECK(cloned_buffer.write(cx, v1, transferable, policy, nullptr, nullptr)); JS::RootedValue v2(cx); diff --git a/js/src/jsapi-tests/testStructuredClone.cpp b/js/src/jsapi-tests/testStructuredClone.cpp index 77df7e9d8035..fe4c9cf68b8b 100644 --- a/js/src/jsapi-tests/testStructuredClone.cpp +++ b/js/src/jsapi-tests/testStructuredClone.cpp @@ -137,8 +137,7 @@ BEGIN_TEST(testStructuredClone_externalArrayBuffer) { END_TEST(testStructuredClone_externalArrayBuffer) BEGIN_TEST(testStructuredClone_externalArrayBufferDifferentThreadOrProcess) { - CHECK(testStructuredCloneCopy( - JS::StructuredCloneScope::SameProcessDifferentThread)); + CHECK(testStructuredCloneCopy(JS::StructuredCloneScope::SameProcess)); CHECK(testStructuredCloneCopy(JS::StructuredCloneScope::DifferentProcess)); return true; } diff --git a/js/src/tests/non262/extensions/clone-errors.js b/js/src/tests/non262/extensions/clone-errors.js index c9d64519c67d..2cc895eb38f7 100644 --- a/js/src/tests/non262/extensions/clone-errors.js +++ b/js/src/tests/non262/extensions/clone-errors.js @@ -23,8 +23,8 @@ check(new Proxy({}, {})); check({get x() { throw new Error("fail"); }}); // Mismatched scopes. -for (let [write_scope, read_scope] of [['SameProcessDifferentThread', 'DifferentProcessForIndexedDB'], - ['SameProcessDifferentThread', 'DifferentProcess']]) +for (let [write_scope, read_scope] of [['SameProcess', 'DifferentProcessForIndexedDB'], + ['SameProcess', 'DifferentProcess']]) { var ab = new ArrayBuffer(12); var buffer = serialize(ab, [ab], { scope: write_scope }); diff --git a/js/src/tests/non262/extensions/clone-transferables.js b/js/src/tests/non262/extensions/clone-transferables.js index 5c39f607a115..6b3ff99079d1 100644 --- a/js/src/tests/non262/extensions/clone-transferables.js +++ b/js/src/tests/non262/extensions/clone-transferables.js @@ -3,7 +3,7 @@ // http://creativecommons.org/licenses/publicdomain/ function* buffer_options() { - for (var scope of ["SameProcessDifferentThread", + for (var scope of ["SameProcess", "DifferentProcess", "DifferentProcessForIndexedDB"]) { diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index 210378de108f..24a5d5debcb7 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -428,7 +428,7 @@ struct JSStructuredCloneReader { SCInput& in; // The widest scope that the caller will accept, where - // SameProcessDifferentThread is the widest (it can store anything it wants) + // SameProcess is the widest (it can store anything it wants) // and DifferentProcess is the narrowest (it cannot contain pointers and must // be valid cross-process.) JS::StructuredCloneScope allowedScope; @@ -1267,7 +1267,7 @@ bool JSStructuredCloneWriter::writeSharedArrayBuffer(HandleObject obj) { // cross-process. The cloneDataPolicy should have guarded against this; // since it did not then throw, with a very explicit message. - if (output().scope() > JS::StructuredCloneScope::SameProcessDifferentThread) { + if (output().scope() > JS::StructuredCloneScope::SameProcess) { JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_SHMEM_POLICY); return false; @@ -2658,10 +2658,10 @@ bool JSStructuredCloneReader::readHeader() { // Backward compatibility with old structured clone buffers. Value '0' was // used for SameProcessSameThread scope. if ((int)storedScope == 0) { - storedScope = JS::StructuredCloneScope::SameProcessDifferentThread; + storedScope = JS::StructuredCloneScope::SameProcess; } - if (storedScope < JS::StructuredCloneScope::SameProcessDifferentThread || + if (storedScope < JS::StructuredCloneScope::SameProcess || storedScope > JS::StructuredCloneScope::DifferentProcessForIndexedDB) { JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, @@ -3090,8 +3090,8 @@ JS_PUBLIC_API bool JS_StructuredClone( const JSStructuredCloneCallbacks* callbacks = optionalCallbacks; - JSAutoStructuredCloneBuffer buf( - JS::StructuredCloneScope::SameProcessDifferentThread, callbacks, closure); + JSAutoStructuredCloneBuffer buf(JS::StructuredCloneScope::SameProcess, + callbacks, closure); { if (value.isObject()) { RootedObject obj(cx, &value.toObject());