Skip to content

Commit

Permalink
Bug 1607791 - Get rid of IDBMutableFile.getFile() - part 3 - Rename S…
Browse files Browse the repository at this point in the history
…ameProcessDifferentThread to SameProcess, r=asuth,sfink

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
bakulf committed Jan 15, 2020
1 parent 7af68b5 commit a9cf344
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 60 deletions.
2 changes: 1 addition & 1 deletion dom/base/PostMessageEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions dom/base/SerializedStackHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
43 changes: 15 additions & 28 deletions dom/base/StructuredCloneHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -904,8 +901,7 @@ JSObject* StructuredCloneHolder::CustomReadHandler(
}

if (aTag == SCTAG_DOM_WASM &&
mStructuredCloneScope ==
StructuredCloneScope::SameProcessDifferentThread) {
mStructuredCloneScope == StructuredCloneScope::SameProcess) {
return ReadWasmModule(aCx, aIndex, this);
}

Expand Down Expand Up @@ -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(),
Expand All @@ -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))) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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 =
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions dom/base/StructuredCloneHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dom/media/webaudio/AudioWorkletNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/MessageEventRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dom/xhr/XMLHttpRequestWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
6 changes: 3 additions & 3 deletions js/public/StructuredClone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*/
Expand Down
15 changes: 7 additions & 8 deletions js/src/builtin/TestingFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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"
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions js/src/jsapi-tests/testMappedArrayBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions js/src/jsapi-tests/testStructuredClone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/tests/non262/extensions/clone-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion js/src/tests/non262/extensions/clone-transferables.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// http://creativecommons.org/licenses/publicdomain/

function* buffer_options() {
for (var scope of ["SameProcessDifferentThread",
for (var scope of ["SameProcess",
"DifferentProcess",
"DifferentProcessForIndexedDB"])
{
Expand Down
12 changes: 6 additions & 6 deletions js/src/vm/StructuredClone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit a9cf344

Please sign in to comment.