2009-12-03 08:16:14 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-07-11 06:33:10 +00:00
|
|
|
|
2009-09-09 22:00:14 +00:00
|
|
|
#ifndef ipc_testshell_TestShellParent_h
|
|
|
|
#define ipc_testshell_TestShellParent_h 1
|
2009-07-11 06:33:10 +00:00
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
#include "mozilla/ipc/PTestShellParent.h"
|
|
|
|
#include "mozilla/ipc/PTestShellCommandParent.h"
|
2009-08-25 23:07:22 +00:00
|
|
|
|
2015-01-23 10:23:57 +00:00
|
|
|
#include "js/RootingAPI.h"
|
2020-11-23 16:21:38 +00:00
|
|
|
#include "js/Value.h"
|
2013-09-23 17:25:00 +00:00
|
|
|
#include "nsString.h"
|
2009-07-11 06:33:10 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2009-11-06 20:43:39 +00:00
|
|
|
|
2009-07-11 06:33:10 +00:00
|
|
|
namespace ipc {
|
|
|
|
|
2009-12-03 08:16:14 +00:00
|
|
|
class TestShellCommandParent;
|
|
|
|
|
|
|
|
class TestShellParent : public PTestShellParent {
|
2019-02-06 15:57:37 +00:00
|
|
|
friend class PTestShellParent;
|
|
|
|
|
2009-12-03 08:16:14 +00:00
|
|
|
public:
|
2024-01-19 20:23:21 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(TestShellParent, override)
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-05-02 18:44:13 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
PTestShellCommandParent* AllocPTestShellCommandParent(
|
2022-07-25 20:19:48 +00:00
|
|
|
const nsAString& aCommand);
|
2009-12-03 08:16:14 +00:00
|
|
|
|
2019-02-06 15:58:07 +00:00
|
|
|
bool DeallocPTestShellCommandParent(PTestShellCommandParent* aActor);
|
2009-12-03 08:16:14 +00:00
|
|
|
|
2022-07-25 20:19:48 +00:00
|
|
|
bool CommandDone(TestShellCommandParent* aActor, const nsAString& aResponse);
|
2024-01-19 20:23:21 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
~TestShellParent() = default;
|
2009-12-03 08:16:14 +00:00
|
|
|
};
|
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
class TestShellCommandParent : public PTestShellCommandParent {
|
2019-02-06 15:57:37 +00:00
|
|
|
friend class PTestShellCommandParent;
|
|
|
|
|
2009-08-25 23:07:22 +00:00
|
|
|
public:
|
2020-02-14 00:57:39 +00:00
|
|
|
TestShellCommandParent() = default;
|
2009-08-25 23:07:22 +00:00
|
|
|
|
2016-09-11 09:15:24 +00:00
|
|
|
bool SetCallback(JSContext* aCx, const JS::Value& aCallback);
|
2009-08-25 23:07:22 +00:00
|
|
|
|
2022-07-25 20:19:48 +00:00
|
|
|
bool RunCallback(const nsAString& aResponse);
|
2009-08-25 23:07:22 +00:00
|
|
|
|
|
|
|
void ReleaseCallback();
|
|
|
|
|
2009-12-03 08:16:14 +00:00
|
|
|
protected:
|
2022-07-25 20:19:48 +00:00
|
|
|
bool ExecuteCallback(const nsAString& aResponse);
|
2011-06-23 23:31:58 +00:00
|
|
|
|
2017-11-06 03:37:28 +00:00
|
|
|
void ActorDestroy(ActorDestroyReason why) override;
|
2013-07-08 15:48:39 +00:00
|
|
|
|
2022-07-25 20:19:48 +00:00
|
|
|
mozilla::ipc::IPCResult Recv__delete__(const nsAString& aResponse) {
|
2016-11-15 03:26:00 +00:00
|
|
|
if (!ExecuteCallback(aResponse)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2009-12-03 08:16:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-25 23:07:22 +00:00
|
|
|
private:
|
2015-01-23 10:23:57 +00:00
|
|
|
JS::PersistentRooted<JS::Value> mCallback;
|
2009-08-25 23:07:22 +00:00
|
|
|
};
|
|
|
|
|
2009-07-11 06:33:10 +00:00
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-09-09 22:00:14 +00:00
|
|
|
#endif /* ipc_testshell_TestShellParent_h */
|