Line data Source code
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 "js/RootingAPI.h"
16 : #include "nsString.h"
17 :
18 : namespace mozilla {
19 :
20 : namespace ipc {
21 :
22 : class TestShellCommandParent;
23 :
24 0 : class TestShellParent : public PTestShellParent
25 : {
26 : public:
27 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
28 :
29 : PTestShellCommandParent*
30 : AllocPTestShellCommandParent(const nsString& aCommand) override;
31 :
32 : bool
33 : DeallocPTestShellCommandParent(PTestShellCommandParent* aActor) override;
34 :
35 : bool
36 : CommandDone(TestShellCommandParent* aActor, const nsString& aResponse);
37 : };
38 :
39 :
40 0 : class TestShellCommandParent : public PTestShellCommandParent
41 : {
42 : public:
43 0 : TestShellCommandParent() {}
44 :
45 : bool SetCallback(JSContext* aCx, const JS::Value& aCallback);
46 :
47 : bool RunCallback(const nsString& aResponse);
48 :
49 : void ReleaseCallback();
50 :
51 : protected:
52 : bool ExecuteCallback(const nsString& aResponse);
53 :
54 : void ActorDestroy(ActorDestroyReason why);
55 :
56 0 : mozilla::ipc::IPCResult Recv__delete__(const nsString& aResponse) {
57 0 : if (!ExecuteCallback(aResponse)) {
58 0 : return IPC_FAIL_NO_REASON(this);
59 : }
60 0 : return IPC_OK();
61 : }
62 :
63 : private:
64 : JS::PersistentRooted<JS::Value> mCallback;
65 : };
66 :
67 :
68 : } /* namespace ipc */
69 : } /* namespace mozilla */
70 :
71 : #endif /* ipc_testshell_TestShellParent_h */
|