Files
palemoon27/js/ipc/JavaScriptChild.cpp
T
roytam1 c0522908da import changes from `dev' branch of rmottola/Arctic-Fox:
- more bits of singature removal (a7f0c4d858)
- Bug 1217218 - Consolidate shutdown of nsPerformanceStatsService. r=froydnj (138a0b20f1)
- Bug 1220407 - include sys/resource.h for struct rusage and getrusage() on all unices, not linux only. r=yoric (fb6a111936)
- Bug 1188248 - Merge jank monitoring and CPOW monitoring (low-level);r=jandem,yoric (54ae55b88a)
- Bug 1198934 - Support special-case WebExtension behavior for TypedArrays. r=billm (055a21fdcb)
- Bug 1214571 - Only create mContextObserver once. r=baku (dfe727d2d5)
- Bug 1215072 - throw in case dictionary initialization fails in canvas.getContext, r=baku (9f3e5e8945)
- bug 1217625 suspend inactive AudioNodeStreams r=padenot (1ce879bdce)
- bug 1210280 use nullptr for silent channels in UpMixDownMixChunk r=padenot (65d7354b19)
- bug 1207003 remove unnecessary EnsureTrack() call r=padenot (14580eda34)
- bug 1207003 coallesce external output chunks when silent r=padenot (136bb0bdc8)
- bug 1207003 only create track for external AudioNodeStreams r=padenot (0a62d97f93)
- bug 1217625 perform checks for transition to inactive outside of stream processing r=padenot (2587cfa37b)
- bug 1205558 remove DelayNodeEngine::mSource r=padenot (c732f2c88c)
- Bug 1103188 - Always check tracks on getUserMedia(). r=jib (6c37e66f9d)
- Bug 1211658 - GUM constraints for screen sharing don't affect framerate. r=jib (46a3274ebb)
- Bug 953265: Update webrtc/getUserMedia default audio capture rate to 32KHz r=padenot (148556edcb)
- Bug 1070216 - Properly manage lifetime of allocated CaptureDevices. r=jib (bbd192727e)
- fix small revert (024171acda)
- Bug 1211656 - GUM Constraints for screen sharing don't affect stream resolution. r=jib (c845e8f781)
2022-10-21 09:25:13 +08:00

84 lines
2.0 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 "JavaScriptChild.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/ipc/MessageChannel.h"
#include "nsContentUtils.h"
#include "xpcprivate.h"
#include "jsfriendapi.h"
#include "AccessCheck.h"
using namespace JS;
using namespace mozilla;
using namespace mozilla::jsipc;
using mozilla::AutoSafeJSContext;
static void
UpdateChildWeakPointersBeforeSweepingZoneGroup(JSRuntime* rt, void* data)
{
static_cast<JavaScriptChild*>(data)->updateWeakPointers();
}
JavaScriptChild::JavaScriptChild(JSRuntime* rt)
: JavaScriptShared(rt),
JavaScriptBase<PJavaScriptChild>(rt)
{
}
JavaScriptChild::~JavaScriptChild()
{
JS_RemoveWeakPointerZoneGroupCallback(rt_, UpdateChildWeakPointersBeforeSweepingZoneGroup);
}
bool
JavaScriptChild::init()
{
if (!WrapperOwner::init())
return false;
if (!WrapperAnswer::init())
return false;
JS_AddWeakPointerZoneGroupCallback(rt_, UpdateChildWeakPointersBeforeSweepingZoneGroup, this);
return true;
}
void
JavaScriptChild::updateWeakPointers()
{
objects_.sweep();
unwaivedObjectIds_.sweep();
waivedObjectIds_.sweep();
}
JSObject*
JavaScriptChild::scopeForTargetObjects()
{
// CPOWs from the parent need to point into the child's privileged junk
// scope so that they can benefit from XrayWrappers in the child.
return xpc::PrivilegedJunkScope();
}
PJavaScriptChild*
mozilla::jsipc::NewJavaScriptChild(JSRuntime* rt)
{
JavaScriptChild* child = new JavaScriptChild(rt);
if (!child->init()) {
delete child;
return nullptr;
}
return child;
}
void
mozilla::jsipc::ReleaseJavaScriptChild(PJavaScriptChild* child)
{
static_cast<JavaScriptChild*>(child)->decref();
}