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