Files
palemoon27/js/ipc/JavaScriptParent.cpp
T
roytam1 d7187c26b6 import changes from `dev' branch of rmottola/Arctic-Fox:
- pointer style (73474b840)
- Bug 1152784 - Be more robust about possible intermediate wrappers in IsFrameId. r=bz (fb81861cc)
- pointer style (c0b667212)
- Bug 1180123 (part 1) - Report the size of the saved stacks sets. r=fitzgen. (e6c3a9609)
- Bug 1180123 (part 2) - Minor nursery report fixes. r=terrence. (172525db9)
- Bug 1181175 - Use RDTSC for Performance Monitoring instead of getrusage. r=jandem (b970bf5f1)
- Bug 1190436 - Part 1: Use more smart pointers in XPConnect. r=gabor (c80d65dee)
- Bug 1190436 - Part 2: Use an early return in XPCConvert::JSObject2NativeInterface. r=gabor (ef2123643)
- Bug 1161491 - schedulePreciseGC should use the normal GC triggering mechanisms, r=mccr8 (42cdfa847)
- pointer style (8a147bec5)
- Bug 1155773 - Remove gotos from XPCConvert::NativeArray2JS(). r=bholley (a8858d358)
- Bug 1164061 - WebRTC - move TMMBR behind pref r=jesup (36ba20713)
- Bug 1164061 - Backout signaling unittest changes for tmmbr r=jesup (f2fbd86be)
- Bug 1165520: Negotiate rtcp-fb r=jesup (449edaa83)
- Bug 1165129: Allow JS to reorder codecs in a local answer. Also means that we'll take the ordering more seriously when we see multiple codecs in a remote answer. r=jesup (c1ab58747)
- Bug 818640 - Test that using dynamic payload types < 96 works. r=mt (dfa3418cf)
- Bug 952145: Rollback support r=mt, r=smaug (28182262b)
- code style (ecaf69b5a)
-  Bug 1187773 - Don't include heapapi.h from js/public. r=jorendorff (40179ec4e)
- pointer style (f6e3d0610)
- Bug 1196590 - Don't assume that objects without shapes are unboxed plain objects, r=jandem. (75cd29b7b)
- Bug 1194430 - Always mark the global jitcode table during major GCs. (r=djvj) (772e96665)
- Bug 1036574 - Revert horrible workaround in baseline IC for magic arg callee. (r=me) (b5f11337a)
- spurious spaces (80b22a36a)
2021-12-10 10:40:05 +08:00

96 lines
2.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=4 sw=4 et 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/. */
#include "JavaScriptParent.h"
#include "mozilla/dom/ContentParent.h"
#include "nsJSUtils.h"
#include "jsfriendapi.h"
#include "jswrapper.h"
#include "js/Proxy.h"
#include "js/HeapAPI.h"
#include "xpcprivate.h"
#include "mozilla/Casting.h"
using namespace js;
using namespace JS;
using namespace mozilla;
using namespace mozilla::jsipc;
using namespace mozilla::dom;
static void
TraceParent(JSTracer* trc, void* data)
{
static_cast<JavaScriptParent*>(data)->trace(trc);
}
JavaScriptParent::JavaScriptParent(JSRuntime* rt)
: JavaScriptShared(rt),
JavaScriptBase<PJavaScriptParent>(rt)
{
}
JavaScriptParent::~JavaScriptParent()
{
JS_RemoveExtraGCRootsTracer(rt_, TraceParent, this);
}
bool
JavaScriptParent::init()
{
if (!WrapperOwner::init())
return false;
JS_AddExtraGCRootsTracer(rt_, TraceParent, this);
return true;
}
void
JavaScriptParent::trace(JSTracer* trc)
{
objects_.trace(trc);
unwaivedObjectIds_.trace(trc);
waivedObjectIds_.trace(trc);
}
JSObject*
JavaScriptParent::scopeForTargetObjects()
{
// CPWOWs from the child need to point into the parent's unprivileged junk
// scope so that a compromised child cannot compromise the parent. In
// practice, this means that a child process can only (a) hold parent
// objects alive and (b) invoke them if they are callable.
return xpc::UnprivilegedJunkScope();
}
mozilla::ipc::IProtocol*
JavaScriptParent::CloneProtocol(Channel* aChannel, ProtocolCloneContext* aCtx)
{
ContentParent* contentParent = aCtx->GetContentParent();
nsAutoPtr<PJavaScriptParent> actor(contentParent->AllocPJavaScriptParent());
if (!actor || !contentParent->RecvPJavaScriptConstructor(actor)) {
return nullptr;
}
return actor.forget();
}
PJavaScriptParent*
mozilla::jsipc::NewJavaScriptParent(JSRuntime* rt)
{
JavaScriptParent* parent = new JavaScriptParent(rt);
if (!parent->init()) {
delete parent;
return nullptr;
}
return parent;
}
void
mozilla::jsipc::ReleaseJavaScriptParent(PJavaScriptParent* parent)
{
static_cast<JavaScriptParent*>(parent)->decref();
}