2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2009-07-10 23:33:10 -07:00
|
|
|
|
|
|
|
#include "TestShellChild.h"
|
2009-11-06 12:43:39 -08:00
|
|
|
#include "mozilla/jsipc/ContextWrapperChild.h"
|
2009-07-10 23:33:10 -07:00
|
|
|
|
|
|
|
using mozilla::ipc::TestShellChild;
|
2009-09-09 15:59:06 -07:00
|
|
|
using mozilla::ipc::PTestShellCommandChild;
|
2009-07-10 23:33:10 -07:00
|
|
|
using mozilla::ipc::XPCShellEnvironment;
|
2009-11-06 12:43:39 -08:00
|
|
|
using mozilla::jsipc::PContextWrapperChild;
|
|
|
|
using mozilla::jsipc::ContextWrapperChild;
|
2009-07-10 23:33:10 -07:00
|
|
|
|
|
|
|
TestShellChild::TestShellChild()
|
2009-08-28 16:16:19 -07:00
|
|
|
: mXPCShell(XPCShellEnvironment::CreateEnvironment())
|
2009-07-10 23:33:10 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-08-25 16:07:22 -07:00
|
|
|
TestShellChild::RecvExecuteCommand(const nsString& aCommand)
|
2009-07-10 23:33:10 -07:00
|
|
|
{
|
2009-07-23 15:27:17 -07:00
|
|
|
if (mXPCShell->IsQuitting()) {
|
|
|
|
NS_WARNING("Commands sent after quit command issued!");
|
2009-09-17 16:09:20 -07:00
|
|
|
return false;
|
2009-07-23 15:27:17 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
return mXPCShell->EvaluateString(aCommand);
|
2009-07-23 15:27:17 -07:00
|
|
|
}
|
2009-07-10 23:33:10 -07:00
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PTestShellCommandChild*
|
2009-09-22 10:31:11 -07:00
|
|
|
TestShellChild::AllocPTestShellCommand(const nsString& aCommand)
|
2009-08-25 16:07:22 -07:00
|
|
|
{
|
2009-09-09 15:59:06 -07:00
|
|
|
return new PTestShellCommandChild();
|
2009-08-25 16:07:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-12-03 00:16:14 -08:00
|
|
|
TestShellChild::DeallocPTestShellCommand(PTestShellCommandChild* aCommand)
|
2009-07-23 15:27:17 -07:00
|
|
|
{
|
2009-08-25 16:07:22 -07:00
|
|
|
delete aCommand;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-25 16:07:22 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2009-09-09 15:59:06 -07:00
|
|
|
TestShellChild::RecvPTestShellCommandConstructor(PTestShellCommandChild* aActor,
|
2009-09-09 15:00:14 -07:00
|
|
|
const nsString& aCommand)
|
2009-08-25 16:07:22 -07:00
|
|
|
{
|
2009-07-10 23:33:10 -07:00
|
|
|
if (mXPCShell->IsQuitting()) {
|
2009-07-23 15:27:17 -07:00
|
|
|
NS_WARNING("Commands sent after quit command issued!");
|
2009-09-17 16:09:20 -07:00
|
|
|
return false;
|
2009-07-10 23:33:10 -07:00
|
|
|
}
|
|
|
|
|
2009-08-25 16:07:22 -07:00
|
|
|
nsString response;
|
|
|
|
if (!mXPCShell->EvaluateString(aCommand, &response)) {
|
2009-09-17 16:09:20 -07:00
|
|
|
return false;
|
2009-08-25 16:07:22 -07:00
|
|
|
}
|
|
|
|
|
2009-12-03 00:16:14 -08:00
|
|
|
return PTestShellCommandChild::Send__delete__(aActor, response);
|
2009-07-10 23:33:10 -07:00
|
|
|
}
|
2009-11-06 12:43:39 -08:00
|
|
|
|
|
|
|
PContextWrapperChild*
|
|
|
|
TestShellChild::AllocPContextWrapper()
|
|
|
|
{
|
|
|
|
JSContext* cx;
|
|
|
|
if (mXPCShell && (cx = mXPCShell->GetContext())) {
|
|
|
|
return new ContextWrapperChild(cx);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TestShellChild::DeallocPContextWrapper(PContextWrapperChild* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|