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
This commit is contained in:
Andrea Marchesini 2020-01-15 12:02:17 +00:00
parent 7af68b55f9
commit a9cf3442be
14 changed files with 43 additions and 60 deletions

View File

@ -60,7 +60,7 @@ class PostMessageEvent final : public Runnable {
mHolder.construct<StructuredCloneHolder>(
StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringSupported,
JS::StructuredCloneScope::SameProcessDifferentThread);
JS::StructuredCloneScope::SameProcess);
mHolder.ref<StructuredCloneHolder>().Write(aCx, aMessage, aTransfer,
aClonePolicy, aError);
}

View File

@ -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) {

View File

@ -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<JS::WasmModule> 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<OffscreenCanvasCloneData*>(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<ImageBitmapCloneData*>(aContent);
RefPtr<ImageBitmap> 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<OffscreenCanvasCloneData*>(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<ImageBitmapCloneData*>(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)) {

View File

@ -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

View File

@ -520,7 +520,7 @@ already_AddRefed<AudioWorkletNode> AudioWorkletNode::Constructor(
MakeUnique<StructuredCloneHolder>(
StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringNotSupported,
JS::StructuredCloneScope::SameProcessDifferentThread);
JS::StructuredCloneScope::SameProcess);
serializedOptions->Write(cx, optionsVal, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;

View File

@ -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,

View File

@ -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) {}

View File

@ -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.
*/

View File

@ -3381,8 +3381,8 @@ static mozilla::Maybe<JS::StructuredCloneScope> 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,

View File

@ -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);

View File

@ -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;
}

View File

@ -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 });

View File

@ -3,7 +3,7 @@
// http://creativecommons.org/licenses/publicdomain/
function* buffer_options() {
for (var scope of ["SameProcessDifferentThread",
for (var scope of ["SameProcess",
"DifferentProcess",
"DifferentProcessForIndexedDB"])
{

View File

@ -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());