This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 305
/
ActivityRequestHandler.js
80 lines (64 loc) · 2.44 KB
/
ActivityRequestHandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsISyncMessageSender");
function debug(aMsg) {
//dump("-- ActivityRequestHandler.js " + Date.now() + " : " + aMsg + "\n");
}
/**
* nsIDOMMozActivityRequestHandler implementation.
*/
function ActivityRequestHandler() {
debug("ActivityRequestHandler");
this.wrappedJSObject = this;
// When a system message of type 'activity' is emitted, it forces the
// creation of an ActivityWrapper which in turns replace the default
// system message callback. The newly created wrapper then create a
// nsIDOMActivityRequestHandler object and fills up the properties of
// this object as well as the properties of the nsIDOMActivityOptions
// object contains by the request handler.
this._id = null;
this._options = Cc["@mozilla.org/dom/activities/options;1"]
.createInstance(Ci.nsIDOMMozActivityOptions);
}
ActivityRequestHandler.prototype = {
__exposedProps__: {
source: "r",
postResult: "r",
postError: "r"
},
get source() {
return this._options;
},
postResult: function arh_postResult(aResult) {
cpmm.sendAsyncMessage("Activity:PostResult", {
"id": this._id,
"result": aResult
});
},
postError: function arh_postError(aError) {
cpmm.sendAsyncMessage("Activity:PostError", {
"id": this._id,
"error": aError
});
},
classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"),
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIDOMMozActivityRequestHandler
]),
classInfo: XPCOMUtils.generateCI({
classID: Components.ID("{9326952a-dbe3-4d81-a51f-d9c160d96d6b}"),
contractID: "@mozilla.org/dom/activities/request-handler;1",
interfaces: [Ci.nsIDOMMozActivityRequestHandler],
flags: Ci.nsIClassInfo.DOM_OBJECT,
classDescription: "Activity Request Handler"
})
}
const NSGetFactory = XPCOMUtils.generateNSGetFactory([ActivityRequestHandler]);