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
|
|
|
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsAutoJSValHolder.h"
|
|
|
|
#include "nsStringGlue.h"
|
2009-07-11 06:33:10 +00:00
|
|
|
|
2009-11-06 20:43:39 +00:00
|
|
|
struct JSContext;
|
|
|
|
struct JSObject;
|
|
|
|
|
2009-07-11 06:33:10 +00:00
|
|
|
namespace mozilla {
|
2009-11-06 20:43:39 +00:00
|
|
|
|
|
|
|
namespace jsipc {
|
|
|
|
class PContextWrapperParent;
|
|
|
|
}
|
|
|
|
|
2009-07-11 06:33:10 +00:00
|
|
|
namespace ipc {
|
|
|
|
|
2009-12-03 08:16:14 +00:00
|
|
|
class TestShellCommandParent;
|
|
|
|
|
|
|
|
class TestShellParent : public PTestShellParent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PTestShellCommandParent*
|
|
|
|
AllocPTestShellCommand(const nsString& aCommand);
|
|
|
|
|
|
|
|
bool
|
|
|
|
DeallocPTestShellCommand(PTestShellCommandParent* aActor);
|
|
|
|
|
|
|
|
bool
|
|
|
|
CommandDone(TestShellCommandParent* aActor, const nsString& aResponse);
|
2009-11-06 20:43:39 +00:00
|
|
|
|
|
|
|
PContextWrapperParent* AllocPContextWrapper();
|
|
|
|
bool DeallocPContextWrapper(PContextWrapperParent* actor);
|
|
|
|
|
2010-03-31 04:41:44 +00:00
|
|
|
JSBool GetGlobalJSObject(JSContext* cx, JSObject** globalp);
|
2009-12-03 08:16:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
class TestShellCommandParent : public PTestShellCommandParent
|
2009-08-25 23:07:22 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
TestShellCommandParent() : mCx(NULL) { }
|
|
|
|
|
|
|
|
JSBool SetCallback(JSContext* aCx,
|
|
|
|
jsval aCallback);
|
|
|
|
|
|
|
|
JSBool RunCallback(const nsString& aResponse);
|
|
|
|
|
|
|
|
void ReleaseCallback();
|
|
|
|
|
2009-12-03 08:16:14 +00:00
|
|
|
protected:
|
2011-06-23 23:31:58 +00:00
|
|
|
bool ExecuteCallback(const nsString& aResponse);
|
|
|
|
|
|
|
|
void ActorDestroy(ActorDestroyReason why);
|
|
|
|
|
2009-12-03 08:16:14 +00:00
|
|
|
bool Recv__delete__(const nsString& aResponse) {
|
2011-06-23 23:31:58 +00:00
|
|
|
return ExecuteCallback(aResponse);
|
2009-12-03 08:16:14 +00:00
|
|
|
}
|
|
|
|
|
2009-08-25 23:07:22 +00:00
|
|
|
private:
|
|
|
|
JSContext* mCx;
|
|
|
|
nsAutoJSValHolder mCallback;
|
|
|
|
};
|
|
|
|
|
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 */
|