Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this
3 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #include "TestShellChild.h"
6 :
7 : using mozilla::ipc::TestShellChild;
8 : using mozilla::ipc::PTestShellCommandChild;
9 : using mozilla::ipc::XPCShellEnvironment;
10 :
11 0 : TestShellChild::TestShellChild()
12 0 : : mXPCShell(XPCShellEnvironment::CreateEnvironment())
13 : {
14 0 : }
15 :
16 : mozilla::ipc::IPCResult
17 0 : TestShellChild::RecvExecuteCommand(const nsString& aCommand)
18 : {
19 0 : if (mXPCShell->IsQuitting()) {
20 0 : NS_WARNING("Commands sent after quit command issued!");
21 0 : return IPC_FAIL_NO_REASON(this);
22 : }
23 :
24 0 : if (!mXPCShell->EvaluateString(aCommand)) {
25 0 : return IPC_FAIL_NO_REASON(this);
26 : }
27 0 : return IPC_OK();
28 : }
29 :
30 : PTestShellCommandChild*
31 0 : TestShellChild::AllocPTestShellCommandChild(const nsString& aCommand)
32 : {
33 0 : return new PTestShellCommandChild();
34 : }
35 :
36 : bool
37 0 : TestShellChild::DeallocPTestShellCommandChild(PTestShellCommandChild* aCommand)
38 : {
39 0 : delete aCommand;
40 0 : return true;
41 : }
42 :
43 : mozilla::ipc::IPCResult
44 0 : TestShellChild::RecvPTestShellCommandConstructor(PTestShellCommandChild* aActor,
45 : const nsString& aCommand)
46 : {
47 0 : if (mXPCShell->IsQuitting()) {
48 0 : NS_WARNING("Commands sent after quit command issued!");
49 0 : return IPC_FAIL_NO_REASON(this);
50 : }
51 :
52 0 : nsString response;
53 0 : if (!mXPCShell->EvaluateString(aCommand, &response)) {
54 0 : return IPC_FAIL_NO_REASON(this);
55 : }
56 :
57 0 : if (!PTestShellCommandChild::Send__delete__(aActor, response)) {
58 0 : return IPC_FAIL_NO_REASON(this);
59 : }
60 0 : return IPC_OK();
61 : }
62 :
|