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/TypeDecls.h"
15 #include "js/RootingAPI.h"
23 class TestShellCommandParent
;
25 class TestShellParent
: public PTestShellParent
{
26 friend class PTestShellParent
;
29 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
31 PTestShellCommandParent
* AllocPTestShellCommandParent(
32 const nsString
& aCommand
);
34 bool DeallocPTestShellCommandParent(PTestShellCommandParent
* aActor
);
36 bool CommandDone(TestShellCommandParent
* aActor
, const nsString
& aResponse
);
39 class TestShellCommandParent
: public PTestShellCommandParent
{
40 friend class PTestShellCommandParent
;
43 TestShellCommandParent() = default;
45 bool SetCallback(JSContext
* aCx
, const JS::Value
& aCallback
);
47 bool RunCallback(const nsString
& aResponse
);
49 void ReleaseCallback();
52 bool ExecuteCallback(const nsString
& aResponse
);
54 void ActorDestroy(ActorDestroyReason why
) override
;
56 mozilla::ipc::IPCResult
Recv__delete__(const nsString
& aResponse
) {
57 if (!ExecuteCallback(aResponse
)) {
58 return IPC_FAIL_NO_REASON(this);
64 JS::PersistentRooted
<JS::Value
> mCallback
;
68 } /* namespace mozilla */
70 #endif /* ipc_testshell_TestShellParent_h */