ipc/testshell/TestShellChild.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/testshell/TestShellChild.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "TestShellChild.h"
     1.9 +
    1.10 +using mozilla::ipc::TestShellChild;
    1.11 +using mozilla::ipc::PTestShellCommandChild;
    1.12 +using mozilla::ipc::XPCShellEnvironment;
    1.13 +
    1.14 +TestShellChild::TestShellChild()
    1.15 +: mXPCShell(XPCShellEnvironment::CreateEnvironment())
    1.16 +{
    1.17 +}
    1.18 +
    1.19 +bool
    1.20 +TestShellChild::RecvExecuteCommand(const nsString& aCommand)
    1.21 +{
    1.22 +  if (mXPCShell->IsQuitting()) {
    1.23 +    NS_WARNING("Commands sent after quit command issued!");
    1.24 +    return false;
    1.25 +  }
    1.26 +
    1.27 +  return mXPCShell->EvaluateString(aCommand);
    1.28 +}
    1.29 +
    1.30 +PTestShellCommandChild*
    1.31 +TestShellChild::AllocPTestShellCommandChild(const nsString& aCommand)
    1.32 +{
    1.33 +  return new PTestShellCommandChild();
    1.34 +}
    1.35 +
    1.36 +bool
    1.37 +TestShellChild::DeallocPTestShellCommandChild(PTestShellCommandChild* aCommand)
    1.38 +{
    1.39 +  delete aCommand;
    1.40 +  return true;
    1.41 +}
    1.42 +
    1.43 +bool
    1.44 +TestShellChild::RecvPTestShellCommandConstructor(PTestShellCommandChild* aActor,
    1.45 +                                                 const nsString& aCommand)
    1.46 +{
    1.47 +  if (mXPCShell->IsQuitting()) {
    1.48 +    NS_WARNING("Commands sent after quit command issued!");
    1.49 +    return false;
    1.50 +  }
    1.51 +
    1.52 +  nsString response;
    1.53 +  if (!mXPCShell->EvaluateString(aCommand, &response)) {
    1.54 +    return false;
    1.55 +  }
    1.56 +
    1.57 +  return PTestShellCommandChild::Send__delete__(aActor, response);
    1.58 +}
    1.59 +

mercurial