|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: sw=2 ts=8 et : |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #ifndef ipc_testshell_TestShellParent_h |
|
9 #define ipc_testshell_TestShellParent_h 1 |
|
10 |
|
11 #include "mozilla/ipc/PTestShellParent.h" |
|
12 #include "mozilla/ipc/PTestShellCommandParent.h" |
|
13 |
|
14 #include "js/TypeDecls.h" |
|
15 #include "nsAutoJSValHolder.h" |
|
16 #include "nsString.h" |
|
17 |
|
18 namespace mozilla { |
|
19 |
|
20 namespace ipc { |
|
21 |
|
22 class TestShellCommandParent; |
|
23 |
|
24 class TestShellParent : public PTestShellParent |
|
25 { |
|
26 public: |
|
27 PTestShellCommandParent* |
|
28 AllocPTestShellCommandParent(const nsString& aCommand); |
|
29 |
|
30 bool |
|
31 DeallocPTestShellCommandParent(PTestShellCommandParent* aActor); |
|
32 |
|
33 bool |
|
34 CommandDone(TestShellCommandParent* aActor, const nsString& aResponse); |
|
35 }; |
|
36 |
|
37 |
|
38 class TestShellCommandParent : public PTestShellCommandParent |
|
39 { |
|
40 public: |
|
41 TestShellCommandParent() : mCx(nullptr) { } |
|
42 |
|
43 bool SetCallback(JSContext* aCx, JS::Value aCallback); |
|
44 |
|
45 bool RunCallback(const nsString& aResponse); |
|
46 |
|
47 void ReleaseCallback(); |
|
48 |
|
49 protected: |
|
50 bool ExecuteCallback(const nsString& aResponse); |
|
51 |
|
52 void ActorDestroy(ActorDestroyReason why); |
|
53 |
|
54 bool Recv__delete__(const nsString& aResponse) { |
|
55 return ExecuteCallback(aResponse); |
|
56 } |
|
57 |
|
58 private: |
|
59 JSContext* mCx; |
|
60 nsAutoJSValHolder mCallback; |
|
61 }; |
|
62 |
|
63 |
|
64 } /* namespace ipc */ |
|
65 } /* namespace mozilla */ |
|
66 |
|
67 #endif /* ipc_testshell_TestShellParent_h */ |