1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=4 sw=4 et tw=80:
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "JavaScriptChild.h"
9 #include "mozilla/dom/ContentChild.h"
10 #include "mozilla/dom/BindingUtils.h"
11 #include "mozilla/ipc/MessageChannel.h"
12 #include "nsContentUtils.h"
13 #include "xpcprivate.h"
14 #include "jsfriendapi.h"
15 #include "AccessCheck.h"
18 using namespace mozilla
;
19 using namespace mozilla::jsipc
;
21 using mozilla::AutoSafeJSContext
;
24 UpdateChildWeakPointersAfterGC(JSRuntime
* rt
, void* data
)
26 static_cast<JavaScriptChild
*>(data
)->updateWeakPointers();
29 JavaScriptChild::JavaScriptChild(JSRuntime
* rt
)
30 : JavaScriptShared(rt
),
31 JavaScriptBase
<PJavaScriptChild
>(rt
)
35 JavaScriptChild::~JavaScriptChild()
37 JS_RemoveWeakPointerCallback(rt_
, UpdateChildWeakPointersAfterGC
);
41 JavaScriptChild::init()
43 if (!WrapperOwner::init())
45 if (!WrapperAnswer::init())
48 JS_AddWeakPointerCallback(rt_
, UpdateChildWeakPointersAfterGC
, this);
53 JavaScriptChild::updateWeakPointers()
56 unwaivedObjectIds_
.sweep();
57 waivedObjectIds_
.sweep();
61 JavaScriptChild::scopeForTargetObjects()
63 // CPOWs from the parent need to point into the child's privileged junk
64 // scope so that they can benefit from XrayWrappers in the child.
65 return xpc::PrivilegedJunkScope();