2013-07-03 11:24:32 +04: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 "JavaScriptParent.h"
|
|
|
|
#include "mozilla/dom/ContentParent.h"
|
|
|
|
#include "nsJSUtils.h"
|
|
|
|
#include "jsfriendapi.h"
|
|
|
|
#include "jsproxy.h"
|
2013-08-18 02:50:18 +04:00
|
|
|
#include "jswrapper.h"
|
2013-07-03 11:24:32 +04:00
|
|
|
#include "HeapAPI.h"
|
|
|
|
#include "xpcprivate.h"
|
|
|
|
#include "mozilla/Casting.h"
|
|
|
|
|
|
|
|
using namespace js;
|
|
|
|
using namespace JS;
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::jsipc;
|
2013-06-03 14:14:37 +04:00
|
|
|
using namespace mozilla::dom;
|
2013-07-03 11:24:32 +04:00
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
static void
|
|
|
|
TraceParent(JSTracer *trc, void *data)
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2014-05-17 03:40:37 +04:00
|
|
|
static_cast<JavaScriptParent *>(data)->trace(trc);
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
JavaScriptParent::JavaScriptParent(JSRuntime *rt)
|
|
|
|
: JavaScriptShared(rt),
|
|
|
|
JavaScriptBase<PJavaScriptParent>(rt)
|
2013-07-11 19:23:34 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
JavaScriptParent::~JavaScriptParent()
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2014-05-17 03:40:37 +04:00
|
|
|
JS_RemoveExtraGCRootsTracer(rt_, TraceParent, this);
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-05-17 03:40:37 +04:00
|
|
|
JavaScriptParent::init()
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2014-05-17 03:40:37 +04:00
|
|
|
if (!WrapperOwner::init())
|
2013-07-03 11:24:32 +04:00
|
|
|
return false;
|
|
|
|
|
2014-05-17 03:40:37 +04:00
|
|
|
JS_AddExtraGCRootsTracer(rt_, TraceParent, this);
|
2013-07-03 11:24:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-17 03:40:37 +04:00
|
|
|
JavaScriptParent::trace(JSTracer *trc)
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2014-05-17 03:40:37 +04:00
|
|
|
if (active())
|
|
|
|
objects_.trace(trc);
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2013-06-03 14:14:37 +04:00
|
|
|
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();
|
|
|
|
}
|