Tue, 06 Jan 2015 21:39:09 +0100
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.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | const Ci = Components.interfaces; |
michael@0 | 8 | const Cu = Components.utils; |
michael@0 | 9 | |
michael@0 | 10 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 11 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 12 | |
michael@0 | 13 | XPCOMUtils.defineLazyServiceGetter(this, "cpmm", |
michael@0 | 14 | "@mozilla.org/childprocessmessagemanager;1", |
michael@0 | 15 | "nsISyncMessageSender"); |
michael@0 | 16 | |
michael@0 | 17 | function debug(aMsg) { |
michael@0 | 18 | //dump("-- ActivityRequestHandler.js " + Date.now() + " : " + aMsg + "\n"); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | /** |
michael@0 | 22 | * nsIDOMMozActivityRequestHandler implementation. |
michael@0 | 23 | */ |
michael@0 | 24 | |
michael@0 | 25 | function ActivityRequestHandler() { |
michael@0 | 26 | debug("ActivityRequestHandler"); |
michael@0 | 27 | |
michael@0 | 28 | // When a system message of type 'activity' is emitted, it forces the |
michael@0 | 29 | // creation of an ActivityWrapper which in turns replace the default |
michael@0 | 30 | // system message callback. The newly created wrapper then create an |
michael@0 | 31 | // ActivityRequestHandler object. |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | ActivityRequestHandler.prototype = { |
michael@0 | 35 | init: function arh_init(aWindow) { |
michael@0 | 36 | this._window = aWindow; |
michael@0 | 37 | }, |
michael@0 | 38 | |
michael@0 | 39 | __init: function arh___init(aId, aOptions) { |
michael@0 | 40 | this._id = aId; |
michael@0 | 41 | this._options = aOptions; |
michael@0 | 42 | }, |
michael@0 | 43 | |
michael@0 | 44 | get source() { |
michael@0 | 45 | // We need to clone this object because the this._options.data has |
michael@0 | 46 | // the type any in WebIDL which will cause the binding layer to pass |
michael@0 | 47 | // the value which is a COW unmodified to content. |
michael@0 | 48 | return Cu.cloneInto(this._options, this._window); |
michael@0 | 49 | }, |
michael@0 | 50 | |
michael@0 | 51 | postResult: function arh_postResult(aResult) { |
michael@0 | 52 | cpmm.sendAsyncMessage("Activity:PostResult", { |
michael@0 | 53 | "id": this._id, |
michael@0 | 54 | "result": aResult |
michael@0 | 55 | }); |
michael@0 | 56 | Services.obs.notifyObservers(null, "activity-success", this._id); |
michael@0 | 57 | }, |
michael@0 | 58 | |
michael@0 | 59 | postError: function arh_postError(aError) { |
michael@0 | 60 | cpmm.sendAsyncMessage("Activity:PostError", { |
michael@0 | 61 | "id": this._id, |
michael@0 | 62 | "error": aError |
michael@0 | 63 | }); |
michael@0 | 64 | Services.obs.notifyObservers(null, "activity-error", this._id); |
michael@0 | 65 | }, |
michael@0 | 66 | |
michael@0 | 67 | classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"), |
michael@0 | 68 | |
michael@0 | 69 | QueryInterface: XPCOMUtils.generateQI([ |
michael@0 | 70 | Ci.nsIDOMGlobalPropertyInitializer |
michael@0 | 71 | ]) |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityRequestHandler]); |