dom/activities/src/ActivityRequestHandler.js

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

mercurial