ipc/testshell/TestShellChild.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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/. */
     5 #include "TestShellChild.h"
     7 using mozilla::ipc::TestShellChild;
     8 using mozilla::ipc::PTestShellCommandChild;
     9 using mozilla::ipc::XPCShellEnvironment;
    11 TestShellChild::TestShellChild()
    12 : mXPCShell(XPCShellEnvironment::CreateEnvironment())
    13 {
    14 }
    16 bool
    17 TestShellChild::RecvExecuteCommand(const nsString& aCommand)
    18 {
    19   if (mXPCShell->IsQuitting()) {
    20     NS_WARNING("Commands sent after quit command issued!");
    21     return false;
    22   }
    24   return mXPCShell->EvaluateString(aCommand);
    25 }
    27 PTestShellCommandChild*
    28 TestShellChild::AllocPTestShellCommandChild(const nsString& aCommand)
    29 {
    30   return new PTestShellCommandChild();
    31 }
    33 bool
    34 TestShellChild::DeallocPTestShellCommandChild(PTestShellCommandChild* aCommand)
    35 {
    36   delete aCommand;
    37   return true;
    38 }
    40 bool
    41 TestShellChild::RecvPTestShellCommandConstructor(PTestShellCommandChild* aActor,
    42                                                  const nsString& aCommand)
    43 {
    44   if (mXPCShell->IsQuitting()) {
    45     NS_WARNING("Commands sent after quit command issued!");
    46     return false;
    47   }
    49   nsString response;
    50   if (!mXPCShell->EvaluateString(aCommand, &response)) {
    51     return false;
    52   }
    54   return PTestShellCommandChild::Send__delete__(aActor, response);
    55 }

mercurial