1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
8 #ifndef ipc_testshell_TestShellParent_h
9 #define ipc_testshell_TestShellParent_h 1
11 #include "mozilla/ipc/PTestShellParent.h"
12 #include "mozilla/ipc/PTestShellCommandParent.h"
14 #include "js/RootingAPI.h"
22 class TestShellCommandParent
;
24 class TestShellParent
: public PTestShellParent
{
25 friend class PTestShellParent
;
28 NS_INLINE_DECL_REFCOUNTING(TestShellParent
, override
)
30 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
32 PTestShellCommandParent
* AllocPTestShellCommandParent(
33 const nsAString
& aCommand
);
35 bool DeallocPTestShellCommandParent(PTestShellCommandParent
* aActor
);
37 bool CommandDone(TestShellCommandParent
* aActor
, const nsAString
& aResponse
);
40 ~TestShellParent() = default;
43 class TestShellCommandParent
: public PTestShellCommandParent
{
44 friend class PTestShellCommandParent
;
47 TestShellCommandParent() = default;
49 bool SetCallback(JSContext
* aCx
, const JS::Value
& aCallback
);
51 bool RunCallback(const nsAString
& aResponse
);
53 void ReleaseCallback();
56 bool ExecuteCallback(const nsAString
& aResponse
);
58 void ActorDestroy(ActorDestroyReason why
) override
;
60 mozilla::ipc::IPCResult
Recv__delete__(const nsAString
& aResponse
) {
61 if (!ExecuteCallback(aResponse
)) {
62 return IPC_FAIL_NO_REASON(this);
68 JS::PersistentRooted
<JS::Value
> mCallback
;
72 } /* namespace mozilla */
74 #endif /* ipc_testshell_TestShellParent_h */