1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/testshell/TestShellParent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#ifndef ipc_testshell_TestShellParent_h 1.12 +#define ipc_testshell_TestShellParent_h 1 1.13 + 1.14 +#include "mozilla/ipc/PTestShellParent.h" 1.15 +#include "mozilla/ipc/PTestShellCommandParent.h" 1.16 + 1.17 +#include "js/TypeDecls.h" 1.18 +#include "nsAutoJSValHolder.h" 1.19 +#include "nsString.h" 1.20 + 1.21 +namespace mozilla { 1.22 + 1.23 +namespace ipc { 1.24 + 1.25 +class TestShellCommandParent; 1.26 + 1.27 +class TestShellParent : public PTestShellParent 1.28 +{ 1.29 +public: 1.30 + PTestShellCommandParent* 1.31 + AllocPTestShellCommandParent(const nsString& aCommand); 1.32 + 1.33 + bool 1.34 + DeallocPTestShellCommandParent(PTestShellCommandParent* aActor); 1.35 + 1.36 + bool 1.37 + CommandDone(TestShellCommandParent* aActor, const nsString& aResponse); 1.38 +}; 1.39 + 1.40 + 1.41 +class TestShellCommandParent : public PTestShellCommandParent 1.42 +{ 1.43 +public: 1.44 + TestShellCommandParent() : mCx(nullptr) { } 1.45 + 1.46 + bool SetCallback(JSContext* aCx, JS::Value aCallback); 1.47 + 1.48 + bool RunCallback(const nsString& aResponse); 1.49 + 1.50 + void ReleaseCallback(); 1.51 + 1.52 +protected: 1.53 + bool ExecuteCallback(const nsString& aResponse); 1.54 + 1.55 + void ActorDestroy(ActorDestroyReason why); 1.56 + 1.57 + bool Recv__delete__(const nsString& aResponse) { 1.58 + return ExecuteCallback(aResponse); 1.59 + } 1.60 + 1.61 +private: 1.62 + JSContext* mCx; 1.63 + nsAutoJSValHolder mCallback; 1.64 +}; 1.65 + 1.66 + 1.67 +} /* namespace ipc */ 1.68 +} /* namespace mozilla */ 1.69 + 1.70 +#endif /* ipc_testshell_TestShellParent_h */