Bug 1731282 [wpt PR 30785] - Fix endpoint URL for a COEP navigation reporting test...
[gecko.git] / ipc / testshell / TestShellParent.h
blobaed6d0d102300b335d77f8a2d0e307e6d36f6396
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/. */
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"
16 #include "js/Value.h"
17 #include "nsString.h"
19 namespace mozilla {
21 namespace ipc {
23 class TestShellCommandParent;
25 class TestShellParent : public PTestShellParent {
26 friend class PTestShellParent;
28 public:
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;
42 public:
43 TestShellCommandParent() = default;
45 bool SetCallback(JSContext* aCx, const JS::Value& aCallback);
47 bool RunCallback(const nsString& aResponse);
49 void ReleaseCallback();
51 protected:
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);
60 return IPC_OK();
63 private:
64 JS::PersistentRooted<JS::Value> mCallback;
67 } /* namespace ipc */
68 } /* namespace mozilla */
70 #endif /* ipc_testshell_TestShellParent_h */