michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyServiceGetter(this, "cpmm", michael@0: "@mozilla.org/childprocessmessagemanager;1", michael@0: "nsISyncMessageSender"); michael@0: michael@0: function debug(aMsg) { michael@0: //dump("-- ActivityRequestHandler.js " + Date.now() + " : " + aMsg + "\n"); michael@0: } michael@0: michael@0: /** michael@0: * nsIDOMMozActivityRequestHandler implementation. michael@0: */ michael@0: michael@0: function ActivityRequestHandler() { michael@0: debug("ActivityRequestHandler"); michael@0: michael@0: // When a system message of type 'activity' is emitted, it forces the michael@0: // creation of an ActivityWrapper which in turns replace the default michael@0: // system message callback. The newly created wrapper then create an michael@0: // ActivityRequestHandler object. michael@0: } michael@0: michael@0: ActivityRequestHandler.prototype = { michael@0: init: function arh_init(aWindow) { michael@0: this._window = aWindow; michael@0: }, michael@0: michael@0: __init: function arh___init(aId, aOptions) { michael@0: this._id = aId; michael@0: this._options = aOptions; michael@0: }, michael@0: michael@0: get source() { michael@0: // We need to clone this object because the this._options.data has michael@0: // the type any in WebIDL which will cause the binding layer to pass michael@0: // the value which is a COW unmodified to content. michael@0: return Cu.cloneInto(this._options, this._window); michael@0: }, michael@0: michael@0: postResult: function arh_postResult(aResult) { michael@0: cpmm.sendAsyncMessage("Activity:PostResult", { michael@0: "id": this._id, michael@0: "result": aResult michael@0: }); michael@0: Services.obs.notifyObservers(null, "activity-success", this._id); michael@0: }, michael@0: michael@0: postError: function arh_postError(aError) { michael@0: cpmm.sendAsyncMessage("Activity:PostError", { michael@0: "id": this._id, michael@0: "error": aError michael@0: }); michael@0: Services.obs.notifyObservers(null, "activity-error", this._id); michael@0: }, michael@0: michael@0: classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"), michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([ michael@0: Ci.nsIDOMGlobalPropertyInitializer michael@0: ]) michael@0: } michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityRequestHandler]);