Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/child/dataCollector.js

Issue 29338283: Issue 3499 - Use the new messaging API for the issue reporter (Closed)
Patch Set: Created March 15, 2016, 10:57 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/ui/sendReport.js ('k') | lib/dataCollector.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/dataCollector.js
===================================================================
--- a/lib/child/dataCollector.js
+++ b/lib/child/dataCollector.js
@@ -21,57 +21,36 @@
*/
"use strict";
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let {Task} = Cu.import("resource://gre/modules/Task.jsm", {});
let {PrivateBrowsingUtils} = Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm", {});
+let {port} = require("messaging");
let {Utils} = require("utils");
-addMessageListener("AdblockPlus:CollectData", onCollectData);
-onShutdown.add(() => {
- removeMessageListener("AdblockPlus:CollectData", onCollectData);
-});
+port.on("collectData", onCollectData);
-function onCollectData(message)
+function onCollectData({outerWindowID, screenshotWidth}, sender)
{
- let {outerWindowID, screenshotWidth, responseID} = message.data;
-
- function success(data)
- {
- sendAsyncMessage("AdblockPlus:CollectDataResponse", {
- responseID,
- data
- });
- }
-
- function error(e)
- {
- Cu.reportError(e);
- sendAsyncMessage("AdblockPlus:CollectDataResponse", {
- responseID,
- data: null
- });
- }
-
let window = Services.wm.getOuterWindowWithId(outerWindowID);
if (window)
{
- Task.spawn(function*()
+ return Task.spawn(function*()
{
let data = {};
data.isPrivate = PrivateBrowsingUtils.isContentWindowPrivate(window);
data.opener = window.opener ? window.opener.location.href : null;
data.referrer = window.document.referrer;
data.frames = yield scanFrames(window);
data.screenshot = yield createScreenshot(window, screenshotWidth);
return data;
- }).then(success, error);
+ });
}
}
function scanFrames(window)
{
let frames = [];
for (let i = 0; i < window.frames.length; i++)
{
« no previous file with comments | « chrome/content/ui/sendReport.js ('k') | lib/dataCollector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld