2012-05-21 15:12:37 +04: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-11 10:33:10 +04:00
|
|
|
|
|
|
|
#include "TestShellChild.h"
|
|
|
|
|
|
|
|
using mozilla::ipc::TestShellChild;
|
2009-09-10 02:59:06 +04:00
|
|
|
using mozilla::ipc::PTestShellCommandChild;
|
2009-07-11 10:33:10 +04:00
|
|
|
using mozilla::ipc::XPCShellEnvironment;
|
|
|
|
|
|
|
|
TestShellChild::TestShellChild()
|
2009-08-29 03:16:19 +04:00
|
|
|
: mXPCShell(XPCShellEnvironment::CreateEnvironment())
|
2009-07-11 10:33:10 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-08-26 03:07:22 +04:00
|
|
|
TestShellChild::RecvExecuteCommand(const nsString& aCommand)
|
2009-07-11 10:33:10 +04:00
|
|
|
{
|
2009-07-24 02:27:17 +04:00
|
|
|
if (mXPCShell->IsQuitting()) {
|
|
|
|
NS_WARNING("Commands sent after quit command issued!");
|
2009-09-18 03:09:20 +04:00
|
|
|
return false;
|
2009-07-24 02:27:17 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
return mXPCShell->EvaluateString(aCommand);
|
2009-07-24 02:27:17 +04:00
|
|
|
}
|
2009-07-11 10:33:10 +04:00
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
PTestShellCommandChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
TestShellChild::AllocPTestShellCommandChild(const nsString& aCommand)
|
2009-08-26 03:07:22 +04:00
|
|
|
{
|
2009-09-10 02:59:06 +04:00
|
|
|
return new PTestShellCommandChild();
|
2009-08-26 03:07:22 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
TestShellChild::DeallocPTestShellCommandChild(PTestShellCommandChild* aCommand)
|
2009-07-24 02:27:17 +04:00
|
|
|
{
|
2009-08-26 03:07:22 +04:00
|
|
|
delete aCommand;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-26 03:07:22 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2009-09-10 02:59:06 +04:00
|
|
|
TestShellChild::RecvPTestShellCommandConstructor(PTestShellCommandChild* aActor,
|
2009-09-10 02:00:14 +04:00
|
|
|
const nsString& aCommand)
|
2009-08-26 03:07:22 +04:00
|
|
|
{
|
2009-07-11 10:33:10 +04:00
|
|
|
if (mXPCShell->IsQuitting()) {
|
2009-07-24 02:27:17 +04:00
|
|
|
NS_WARNING("Commands sent after quit command issued!");
|
2009-09-18 03:09:20 +04:00
|
|
|
return false;
|
2009-07-11 10:33:10 +04:00
|
|
|
}
|
|
|
|
|
2009-08-26 03:07:22 +04:00
|
|
|
nsString response;
|
|
|
|
if (!mXPCShell->EvaluateString(aCommand, &response)) {
|
2009-09-18 03:09:20 +04:00
|
|
|
return false;
|
2009-08-26 03:07:22 +04:00
|
|
|
}
|
|
|
|
|
2009-12-03 11:16:14 +03:00
|
|
|
return PTestShellCommandChild::Send__delete__(aActor, response);
|
2009-07-11 10:33:10 +04:00
|
|
|
}
|
2009-11-06 23:43:39 +03:00
|
|
|
|