2013-07-03 00:24:32 -07:00
|
|
|
/* -*- 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"
|
2013-08-01 16:45:17 -07:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2014-08-05 21:43:36 -07:00
|
|
|
#include "mozilla/ipc/MessageChannel.h"
|
2013-07-03 00:24:32 -07:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "xpcprivate.h"
|
|
|
|
#include "jsfriendapi.h"
|
2014-08-05 21:43:36 -07:00
|
|
|
#include "AccessCheck.h"
|
2013-07-03 00:24:32 -07:00
|
|
|
|
|
|
|
using namespace JS;
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::jsipc;
|
|
|
|
|
|
|
|
using mozilla::AutoSafeJSContext;
|
|
|
|
|
|
|
|
static void
|
2014-05-16 16:40:37 -07:00
|
|
|
FinalizeChild(JSFreeOp *fop, JSFinalizeStatus status, bool isCompartment, void *data)
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
2014-05-16 16:40:37 -07:00
|
|
|
if (status == JSFINALIZE_GROUP_START) {
|
|
|
|
static_cast<JavaScriptChild *>(data)->finalize(fop);
|
|
|
|
}
|
2013-07-03 00:24:32 -07:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:40:37 -07:00
|
|
|
JavaScriptChild::JavaScriptChild(JSRuntime *rt)
|
|
|
|
: JavaScriptShared(rt),
|
|
|
|
JavaScriptBase<PJavaScriptChild>(rt)
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:40:37 -07:00
|
|
|
JavaScriptChild::~JavaScriptChild()
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
2014-05-16 16:40:37 -07:00
|
|
|
JS_RemoveFinalizeCallback(rt_, FinalizeChild);
|
2013-07-03 00:24:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
JavaScriptChild::init()
|
|
|
|
{
|
2014-05-16 16:40:36 -07:00
|
|
|
if (!WrapperOwner::init())
|
2013-07-03 00:24:32 -07:00
|
|
|
return false;
|
2014-05-16 16:40:36 -07:00
|
|
|
if (!WrapperAnswer::init())
|
|
|
|
return false;
|
|
|
|
|
2014-05-16 16:40:37 -07:00
|
|
|
JS_AddFinalizeCallback(rt_, FinalizeChild, this);
|
2013-07-03 00:24:32 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:40:37 -07:00
|
|
|
void
|
|
|
|
JavaScriptChild::finalize(JSFreeOp *fop)
|
2013-07-03 00:24:32 -07:00
|
|
|
{
|
2014-05-16 16:40:37 -07:00
|
|
|
objects_.finalize(fop);
|
|
|
|
objectIds_.finalize(fop);
|
2013-07-03 00:24:32 -07:00
|
|
|
}
|