2009-12-03 11:16:14 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 15:12:37 +04: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 10:33:10 +04:00
|
|
|
|
2009-09-10 02:00:14 +04:00
|
|
|
#ifndef ipc_testshell_TestShellParent_h
|
|
|
|
#define ipc_testshell_TestShellParent_h 1
|
2009-07-11 10:33:10 +04:00
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
#include "mozilla/ipc/PTestShellParent.h"
|
|
|
|
#include "mozilla/ipc/PTestShellCommandParent.h"
|
2009-08-26 03:07:22 +04:00
|
|
|
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2015-01-23 13:23:57 +03:00
|
|
|
#include "js/RootingAPI.h"
|
2013-09-23 21:25:00 +04:00
|
|
|
#include "nsString.h"
|
2009-07-11 10:33:10 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2009-11-06 23:43:39 +03:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
namespace ipc {
|
|
|
|
|
2009-12-03 11:16:14 +03:00
|
|
|
class TestShellCommandParent;
|
|
|
|
|
|
|
|
class TestShellParent : public PTestShellParent
|
|
|
|
{
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-05-02 22:44:13 +04:00
|
|
|
|
2009-12-03 11:16:14 +03:00
|
|
|
PTestShellCommandParent*
|
2015-03-21 19:28:04 +03:00
|
|
|
AllocPTestShellCommandParent(const nsString& aCommand) override;
|
2009-12-03 11:16:14 +03:00
|
|
|
|
|
|
|
bool
|
2015-03-21 19:28:04 +03:00
|
|
|
DeallocPTestShellCommandParent(PTestShellCommandParent* aActor) override;
|
2009-12-03 11:16:14 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
CommandDone(TestShellCommandParent* aActor, const nsString& aResponse);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
class TestShellCommandParent : public PTestShellCommandParent
|
2009-08-26 03:07:22 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-08-08 17:01:25 +04:00
|
|
|
TestShellCommandParent() {}
|
2009-08-26 03:07:22 +04:00
|
|
|
|
2016-09-11 12:15:24 +03:00
|
|
|
bool SetCallback(JSContext* aCx, const JS::Value& aCallback);
|
2009-08-26 03:07:22 +04:00
|
|
|
|
2013-08-09 02:53:04 +04:00
|
|
|
bool RunCallback(const nsString& aResponse);
|
2009-08-26 03:07:22 +04:00
|
|
|
|
|
|
|
void ReleaseCallback();
|
|
|
|
|
2009-12-03 11:16:14 +03:00
|
|
|
protected:
|
2011-06-24 03:31:58 +04:00
|
|
|
bool ExecuteCallback(const nsString& aResponse);
|
|
|
|
|
|
|
|
void ActorDestroy(ActorDestroyReason why);
|
2013-07-08 19:48:39 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult Recv__delete__(const nsString& aResponse) {
|
|
|
|
if (!ExecuteCallback(aResponse)) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2009-12-03 11:16:14 +03:00
|
|
|
}
|
|
|
|
|
2009-08-26 03:07:22 +04:00
|
|
|
private:
|
2015-01-23 13:23:57 +03:00
|
|
|
JS::PersistentRooted<JS::Value> mCallback;
|
2009-08-26 03:07:22 +04:00
|
|
|
};
|
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
|
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-09-10 02:00:14 +04:00
|
|
|
#endif /* ipc_testshell_TestShellParent_h */
|