|
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 TestShellChild::TestShellChild() |
|
12 : mXPCShell(XPCShellEnvironment::CreateEnvironment()) |
|
13 { |
|
14 } |
|
15 |
|
16 bool |
|
17 TestShellChild::RecvExecuteCommand(const nsString& aCommand) |
|
18 { |
|
19 if (mXPCShell->IsQuitting()) { |
|
20 NS_WARNING("Commands sent after quit command issued!"); |
|
21 return false; |
|
22 } |
|
23 |
|
24 return mXPCShell->EvaluateString(aCommand); |
|
25 } |
|
26 |
|
27 PTestShellCommandChild* |
|
28 TestShellChild::AllocPTestShellCommandChild(const nsString& aCommand) |
|
29 { |
|
30 return new PTestShellCommandChild(); |
|
31 } |
|
32 |
|
33 bool |
|
34 TestShellChild::DeallocPTestShellCommandChild(PTestShellCommandChild* aCommand) |
|
35 { |
|
36 delete aCommand; |
|
37 return true; |
|
38 } |
|
39 |
|
40 bool |
|
41 TestShellChild::RecvPTestShellCommandConstructor(PTestShellCommandChild* aActor, |
|
42 const nsString& aCommand) |
|
43 { |
|
44 if (mXPCShell->IsQuitting()) { |
|
45 NS_WARNING("Commands sent after quit command issued!"); |
|
46 return false; |
|
47 } |
|
48 |
|
49 nsString response; |
|
50 if (!mXPCShell->EvaluateString(aCommand, &response)) { |
|
51 return false; |
|
52 } |
|
53 |
|
54 return PTestShellCommandChild::Send__delete__(aActor, response); |
|
55 } |
|
56 |