tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestShellChild.cpp (1585B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #include "TestShellChild.h"
      6 
      7 using mozilla::ipc::PTestShellCommandChild;
      8 using mozilla::ipc::TestShellChild;
      9 using mozilla::ipc::XPCShellEnvironment;
     10 
     11 TestShellChild::TestShellChild()
     12    : mXPCShell(XPCShellEnvironment::CreateEnvironment()) {}
     13 
     14 mozilla::ipc::IPCResult TestShellChild::RecvExecuteCommand(
     15    const nsAString& aCommand) {
     16  if (mXPCShell->IsQuitting()) {
     17    NS_WARNING("Commands sent after quit command issued!");
     18    return IPC_FAIL_NO_REASON(this);
     19  }
     20 
     21  if (!mXPCShell->EvaluateString(aCommand)) {
     22    return IPC_FAIL_NO_REASON(this);
     23  }
     24  return IPC_OK();
     25 }
     26 
     27 PTestShellCommandChild* TestShellChild::AllocPTestShellCommandChild(
     28    const nsAString& aCommand) {
     29  return new PTestShellCommandChild();
     30 }
     31 
     32 bool TestShellChild::DeallocPTestShellCommandChild(
     33    PTestShellCommandChild* aCommand) {
     34  delete aCommand;
     35  return true;
     36 }
     37 
     38 mozilla::ipc::IPCResult TestShellChild::RecvPTestShellCommandConstructor(
     39    PTestShellCommandChild* aActor, const nsAString& aCommand) {
     40  if (mXPCShell->IsQuitting()) {
     41    NS_WARNING("Commands sent after quit command issued!");
     42    return IPC_FAIL_NO_REASON(this);
     43  }
     44 
     45  nsString response;
     46  if (!mXPCShell->EvaluateString(aCommand, &response)) {
     47    return IPC_FAIL_NO_REASON(this);
     48  }
     49 
     50  if (!PTestShellCommandChild::Send__delete__(aActor, response)) {
     51    return IPC_FAIL_NO_REASON(this);
     52  }
     53  return IPC_OK();
     54 }