b2g/simulator/lib/main.js

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/.
     4  */
     6 const { Cc, Ci, Cu } = require("chrome");
     8 const { SimulatorProcess } = require("./simulator-process");
     9 const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
    10 const Self = require("sdk/self");
    11 const System = require("sdk/system");
    12 const { Simulator } = Cu.import("resource://gre/modules/devtools/Simulator.jsm");
    14 let process;
    16 function launch({ port }) {
    17   // Close already opened simulation
    18   if (process) {
    19     return close().then(launch.bind(null, { port: port }));
    20   }
    22   process = SimulatorProcess();
    23   process.remoteDebuggerPort = port;
    24   process.run();
    26   return promise.resolve();
    27 }
    29 function close() {
    30   if (!process) {
    31     return promise.resolve();
    32   }
    33   let p = process;
    34   process = null;
    35   return p.kill();
    36 }
    39 // Load data generated at build time that
    40 // expose various information about the runtime we ship
    41 let appinfo = System.staticArgs;
    43 Simulator.register(appinfo.label, {
    44   appinfo: appinfo,
    45   launch: launch,
    46   close: close
    47 });
    49 require("sdk/system/unload").when(function () {
    50   Simulator.unregister(appinfo.label);
    51   close();
    52 });

mercurial