Skip to content

Commit

Permalink
Bug 1203920 - Get rid of JS_SetStructuredCloneCallbacks, r=sfink
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed Sep 29, 2015
1 parent de428df commit 1966fab
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 40 deletions.
3 changes: 0 additions & 3 deletions js/public/StructuredClone.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) {
#define JS_SCERR_TRANSFERABLE 1
#define JS_SCERR_DUP_TRANSFERABLE 2

JS_PUBLIC_API(void)
JS_SetStructuredCloneCallbacks(JSRuntime* rt, const JSStructuredCloneCallbacks* callbacks);

JS_PUBLIC_API(bool)
JS_ReadUint32Pair(JSStructuredCloneReader* r, uint32_t* p1, uint32_t* p2);

Expand Down
10 changes: 4 additions & 6 deletions js/src/jsapi-tests/testMappedArrayBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ bool TestCloneObject()
CHECK(obj1);
JSAutoStructuredCloneBuffer cloned_buffer;
JS::RootedValue v1(cx, JS::ObjectValue(*obj1));
const JSStructuredCloneCallbacks* callbacks = js::GetContextStructuredCloneCallbacks(cx);
CHECK(cloned_buffer.write(cx, v1, callbacks, nullptr));
CHECK(cloned_buffer.write(cx, v1, nullptr, nullptr));
JS::RootedValue v2(cx);
CHECK(cloned_buffer.read(cx, &v2, callbacks, nullptr));
CHECK(cloned_buffer.read(cx, &v2, nullptr, nullptr));
JS::RootedObject obj2(cx, v2.toObjectOrNull());
CHECK(VerifyObject(obj2, 8, 12, false));

Expand Down Expand Up @@ -162,10 +161,9 @@ bool TestTransferObject()
JS::RootedValue transferable(cx, JS::ObjectValue(*obj));

JSAutoStructuredCloneBuffer cloned_buffer;
const JSStructuredCloneCallbacks* callbacks = js::GetContextStructuredCloneCallbacks(cx);
CHECK(cloned_buffer.write(cx, v1, transferable, callbacks, nullptr));
CHECK(cloned_buffer.write(cx, v1, transferable, nullptr, nullptr));
JS::RootedValue v2(cx);
CHECK(cloned_buffer.read(cx, &v2, callbacks, nullptr));
CHECK(cloned_buffer.read(cx, &v2, nullptr, nullptr));
JS::RootedObject obj2(cx, v2.toObjectOrNull());
CHECK(VerifyObject(obj2, 8, 12, true));
CHECK(isNeutered(obj1));
Expand Down
6 changes: 0 additions & 6 deletions js/src/jsfriendapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,6 @@ js::DumpHeap(JSRuntime* rt, FILE* fp, js::DumpHeapNurseryBehaviour nurseryBehavi
fflush(dtrc.output);
}

JS_FRIEND_API(const JSStructuredCloneCallbacks*)
js::GetContextStructuredCloneCallbacks(JSContext* cx)
{
return cx->runtime()->structuredCloneCallbacks;
}

JS_FRIEND_API(bool)
js::ContextHasOutstandingRequests(const JSContext* cx)
{
Expand Down
3 changes: 0 additions & 3 deletions js/src/jsfriendapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,6 @@ typedef void
JS_FRIEND_API(void)
SetActivityCallback(JSRuntime* rt, ActivityCallback cb, void* arg);

extern JS_FRIEND_API(const JSStructuredCloneCallbacks*)
GetContextStructuredCloneCallbacks(JSContext* cx);

typedef bool
(* DOMInstanceClassHasProtoAtDepth)(const Class* instanceClass,
uint32_t protoID, uint32_t depth);
Expand Down
1 change: 0 additions & 1 deletion js/src/vm/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
securityCallbacks(const_cast<JSSecurityCallbacks*>(&NullSecurityCallbacks)),
DOMcallbacks(nullptr),
destroyPrincipals(nullptr),
structuredCloneCallbacks(nullptr),
errorReporter(nullptr),
linkedAsmJSModules(nullptr),
propertyRemovals(0),
Expand Down
3 changes: 0 additions & 3 deletions js/src/vm/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -1154,9 +1154,6 @@ struct JSRuntime : public JS::shadow::Runtime,
const js::DOMCallbacks* DOMcallbacks;
JSDestroyPrincipalsOp destroyPrincipals;

/* Structured data callbacks are runtime-wide. */
const JSStructuredCloneCallbacks* structuredCloneCallbacks;

/* Optional error reporter. */
JSErrorReporter errorReporter;

Expand Down
21 changes: 3 additions & 18 deletions js/src/vm/StructuredClone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1966,10 +1966,7 @@ JS_ReadStructuredClone(JSContext* cx, uint64_t* buf, size_t nbytes,
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SC_BAD_CLONE_VERSION);
return false;
}
const JSStructuredCloneCallbacks* callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime()->structuredCloneCallbacks;
const JSStructuredCloneCallbacks* callbacks = optionalCallbacks;
return ReadStructuredClone(cx, buf, nbytes, vp, callbacks, closure);
}

Expand All @@ -1982,10 +1979,7 @@ JS_WriteStructuredClone(JSContext* cx, HandleValue value, uint64_t** bufp, size_
CHECK_REQUEST(cx);
assertSameCompartment(cx, value);

const JSStructuredCloneCallbacks* callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime()->structuredCloneCallbacks;
const JSStructuredCloneCallbacks* callbacks = optionalCallbacks;
return WriteStructuredClone(cx, value, bufp, nbytesp, callbacks, closure, transferable);
}

Expand Down Expand Up @@ -2028,10 +2022,7 @@ JS_StructuredClone(JSContext* cx, HandleValue value, MutableHandleValue vp,
return true;
}

const JSStructuredCloneCallbacks* callbacks =
optionalCallbacks ?
optionalCallbacks :
cx->runtime()->structuredCloneCallbacks;
const JSStructuredCloneCallbacks* callbacks = optionalCallbacks;

JSAutoStructuredCloneBuffer buf;
{
Expand Down Expand Up @@ -2174,12 +2165,6 @@ JSAutoStructuredCloneBuffer::write(JSContext* cx, HandleValue value,
return ok;
}

JS_PUBLIC_API(void)
JS_SetStructuredCloneCallbacks(JSRuntime* rt, const JSStructuredCloneCallbacks* callbacks)
{
rt->structuredCloneCallbacks = callbacks;
}

JS_PUBLIC_API(bool)
JS_ReadUint32Pair(JSStructuredCloneReader* r, uint32_t* p1, uint32_t* p2)
{
Expand Down

0 comments on commit 1966fab

Please sign in to comment.