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"
22 class TestShellCommandParent
;
24 class TestShellParent
: public PTestShellParent
{
25 friend class PTestShellParent
;
28 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
30 PTestShellCommandParent
* AllocPTestShellCommandParent(
31 const nsString
& aCommand
);
33 bool DeallocPTestShellCommandParent(PTestShellCommandParent
* aActor
);
35 bool CommandDone(TestShellCommandParent
* aActor
, const nsString
& aResponse
);
38 class TestShellCommandParent
: public PTestShellCommandParent
{
39 friend class PTestShellCommandParent
;
42 TestShellCommandParent() {}
44 bool SetCallback(JSContext
* aCx
, const JS::Value
& aCallback
);
46 bool RunCallback(const nsString
& aResponse
);
48 void ReleaseCallback();
51 bool ExecuteCallback(const nsString
& aResponse
);
53 void ActorDestroy(ActorDestroyReason why
) override
;
55 mozilla::ipc::IPCResult
Recv__delete__(const nsString
& aResponse
) override
{
56 if (!ExecuteCallback(aResponse
)) {
57 return IPC_FAIL_NO_REASON(this);
63 JS::PersistentRooted
<JS::Value
> mCallback
;
67 } /* namespace mozilla */
69 #endif /* ipc_testshell_TestShellParent_h */