michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=8 et : michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef ipc_testshell_TestShellParent_h michael@0: #define ipc_testshell_TestShellParent_h 1 michael@0: michael@0: #include "mozilla/ipc/PTestShellParent.h" michael@0: #include "mozilla/ipc/PTestShellCommandParent.h" michael@0: michael@0: #include "js/TypeDecls.h" michael@0: #include "nsAutoJSValHolder.h" michael@0: #include "nsString.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace ipc { michael@0: michael@0: class TestShellCommandParent; michael@0: michael@0: class TestShellParent : public PTestShellParent michael@0: { michael@0: public: michael@0: PTestShellCommandParent* michael@0: AllocPTestShellCommandParent(const nsString& aCommand); michael@0: michael@0: bool michael@0: DeallocPTestShellCommandParent(PTestShellCommandParent* aActor); michael@0: michael@0: bool michael@0: CommandDone(TestShellCommandParent* aActor, const nsString& aResponse); michael@0: }; michael@0: michael@0: michael@0: class TestShellCommandParent : public PTestShellCommandParent michael@0: { michael@0: public: michael@0: TestShellCommandParent() : mCx(nullptr) { } michael@0: michael@0: bool SetCallback(JSContext* aCx, JS::Value aCallback); michael@0: michael@0: bool RunCallback(const nsString& aResponse); michael@0: michael@0: void ReleaseCallback(); michael@0: michael@0: protected: michael@0: bool ExecuteCallback(const nsString& aResponse); michael@0: michael@0: void ActorDestroy(ActorDestroyReason why); michael@0: michael@0: bool Recv__delete__(const nsString& aResponse) { michael@0: return ExecuteCallback(aResponse); michael@0: } michael@0: michael@0: private: michael@0: JSContext* mCx; michael@0: nsAutoJSValHolder mCallback; michael@0: }; michael@0: michael@0: michael@0: } /* namespace ipc */ michael@0: } /* namespace mozilla */ michael@0: michael@0: #endif /* ipc_testshell_TestShellParent_h */