[Pkg-mozext-commits] [adblock-plus] 36/87: Issue 3499 - Use the new messaging API for the issue reporter
David Prévot
taffit at moszumanska.debian.org
Sat Apr 30 17:59:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 7b253c4fca34dc2cd61d242f5725bccdcbb3ef28
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Mar 15 11:25:35 2016 +0100
Issue 3499 - Use the new messaging API for the issue reporter
---
chrome/content/ui/sendReport.js | 6 ++--
lib/child/dataCollector.js | 31 ++++-----------------
lib/dataCollector.js | 61 -----------------------------------------
3 files changed, 9 insertions(+), 89 deletions(-)
diff --git a/chrome/content/ui/sendReport.js b/chrome/content/ui/sendReport.js
index 89aa61f..1ca1969 100644
--- a/chrome/content/ui/sendReport.js
+++ b/chrome/content/ui/sendReport.js
@@ -317,9 +317,11 @@ var remoteDataSource =
{
collectData: function(outerWindowID, windowURI, browser, callback)
{
- let dataCollector = require("dataCollector");
+ let {port} = require("messaging");
let screenshotWidth = screenshotDataSource.getWidth();
- dataCollector.collectData(outerWindowID, screenshotWidth, data => {
+ port.emitWithResponse("collectData", {outerWindowID, screenshotWidth})
+ .then(data =>
+ {
screenshotDataSource.setData(data && data.screenshot);
framesDataSource.setData(windowURI, data && data.opener, data && data.referrer, data && data.frames);
diff --git a/lib/child/dataCollector.js b/lib/child/dataCollector.js
index 93a6f9d..85c3598 100644
--- a/lib/child/dataCollector.js
+++ b/lib/child/dataCollector.js
@@ -26,38 +26,17 @@ 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);
@@ -66,7 +45,7 @@ function onCollectData(message)
data.frames = yield scanFrames(window);
data.screenshot = yield createScreenshot(window, screenshotWidth);
return data;
- }).then(success, error);
+ });
}
}
diff --git a/lib/dataCollector.js b/lib/dataCollector.js
deleted file mode 100644
index ee097ae..0000000
--- a/lib/dataCollector.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file is part of Adblock Plus <https://adblockplus.org/>,
- * Copyright (C) 2006-2016 Eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/**
- * @fileOverview Collects some data for a content window, to be attached to
- * issue reports.
- */
-
-"use strict";
-
-let {Utils} = require("utils");
-
-let maxResponseID = 0;
-let callbacks = new Map();
-
-let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"]
- .getService(Ci.nsIMessageListenerManager)
- .QueryInterface(Ci.nsIMessageBroadcaster);
-
-Utils.addChildMessageListener("AdblockPlus:CollectDataResponse", onResponse);
-
-function onResponse({responseID, data})
-{
- let callback = callbacks.get(responseID);
- callbacks.delete(responseID);
- if (typeof callback == "function")
- callback(data);
-}
-
-/**
- * Collects data for the given window.
- * @param {number} outerWindowID the ID of the window
- * @param {number} screenshotWidth width of the screenshot to be created
- * @param {Function} callback function to be called with the data
- */
-function collectData(outerWindowID, screenshotWidth, callback)
-{
- let id = ++maxResponseID;
- callbacks.set(id, callback);
-
- messageManager.broadcastAsyncMessage("AdblockPlus:CollectData", {
- outerWindowID,
- screenshotWidth,
- responseID: id
- });
-}
-exports.collectData = collectData;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list