Bug 1343774 - remove unused functions;r=Honza

MozReview-Commit-ID: CCB8o7mXOPR

--HG--
extra : rebase_source : 707c92c992e00aa7de8c9d28a1d85b6f8ea44d28
This commit is contained in:
Fred Lin 2017-04-07 11:55:13 +08:00
parent 6771c4ebbd
commit 3d18a99f39
2 changed files with 60 additions and 82 deletions

View File

@ -126,7 +126,7 @@ var NetMonitorController = {
}
this._disconnection = new Promise(async (resolve) => {
// Wait for the connection to finish first.
if (!this.isConnected()) {
if (!this._connected) {
await this._connection;
}
@ -148,22 +148,6 @@ var NetMonitorController = {
return this._disconnection;
},
/**
* Checks whether the netmonitor connection is active.
* @return boolean
*/
isConnected: function () {
return !!this._connected;
},
/**
* Gets the activity currently performed by the frontend.
* @return number
*/
getCurrentActivity: function () {
return this._currentActivity || ACTIVITY_TYPE.NONE;
},
/**
* Triggers a specific "activity" to be performed by the frontend.
* This can be, for example, triggering reloads or enabling/disabling cache.
@ -288,18 +272,8 @@ var NetMonitorController = {
*/
get supportsCustomRequest() {
return this.webConsoleClient &&
(this.webConsoleClient.traits.customNetworkRequest ||
!this._target.isApp);
},
/**
* Getter that tells if the server includes the transferred (compressed /
* encoded) response size.
* @type boolean
*/
get supportsTransferredResponseSize() {
return this.webConsoleClient &&
this.webConsoleClient.traits.transferredResponseSize;
(this.webConsoleClient.traits.customNetworkRequest ||
!this._target.isApp);
},
/**
@ -308,7 +282,7 @@ var NetMonitorController = {
*/
get supportsPerfStats() {
return this.tabClient &&
(this.tabClient.traits.reconfigure || !this._target.isApp);
(this.tabClient.traits.reconfigure || !this._target.isApp);
},
/**
@ -319,54 +293,6 @@ var NetMonitorController = {
this.toolbox.viewSourceInDebugger(sourceURL, sourceLine);
}
},
/**
* Start monitoring all incoming update events about network requests and wait until
* a complete info about all requests is received. (We wait for the timings info
* explicitly, because that's always the last piece of information that is received.)
*
* This method is designed to wait for network requests that are issued during a page
* load, when retrieving page resources (scripts, styles, images). It has certain
* assumptions that can make it unsuitable for other types of network communication:
* - it waits for at least one network request to start and finish before returning
* - it waits only for request that were issued after it was called. Requests that are
* already in mid-flight will be ignored.
* - the request start and end times are overlapping. If a new request starts a moment
* after the previous one was finished, the wait will be ended in the "interim"
* period.
* @returns a promise that resolves when the wait is done.
* TODO: should be unified with whenDataAvailable in netmonitor-view.js
*/
waitForAllRequestsFinished() {
return new Promise(resolve => {
// Key is the request id, value is a boolean - is request finished or not?
let requests = new Map();
function onRequest(_, id) {
requests.set(id, false);
}
function onTimings(_, id) {
requests.set(id, true);
maybeResolve();
}
function maybeResolve() {
// Have all the requests in the map finished yet?
if (![...requests.values()].every(finished => finished)) {
return;
}
// All requests are done - unsubscribe from events and resolve!
window.off(EVENTS.NETWORK_EVENT, onRequest);
window.off(EVENTS.RECEIVED_EVENT_TIMINGS, onTimings);
resolve();
}
window.on(EVENTS.NETWORK_EVENT, onRequest);
window.on(EVENTS.RECEIVED_EVENT_TIMINGS, onTimings);
});
},
};
/**

View File

@ -1,12 +1,13 @@
Components.utils.import("resource://devtools/client/framework/gDevTools.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const {devtools} =
const { devtools } =
Components.utils.import("resource://devtools/shared/Loader.jsm", {});
const { getActiveTab } = devtools.require("sdk/tabs/utils");
const { getMostRecentBrowserWindow } = devtools.require("sdk/window/utils");
const ThreadSafeChromeUtils = devtools.require("ThreadSafeChromeUtils");
const {Task} = Cu.import("resource://gre/modules/Task.jsm", {});
const { EVENTS } = devtools.require("devtools/client/netmonitor/src/constants");
const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
const webserver = Services.prefs.getCharPref("addon.test.damp.webserver");
@ -115,9 +116,8 @@ Damp.prototype = {
},
waitForNetworkRequests: Task.async(function*(label, toolbox) {
const { NetMonitorController } = toolbox.getCurrentPanel().panelWin;
const start = performance.now();
yield NetMonitorController.waitForAllRequestsFinished();
yield this.waitForAllRequestsFinished();
const end = performance.now();
this._results.push({
name: label + ".requestsFinished.DAMP",
@ -444,6 +444,58 @@ Damp.prototype = {
}
},
/**
* Start monitoring all incoming update events about network requests and wait until
* a complete info about all requests is received. (We wait for the timings info
* explicitly, because that's always the last piece of information that is received.)
*
* This method is designed to wait for network requests that are issued during a page
* load, when retrieving page resources (scripts, styles, images). It has certain
* assumptions that can make it unsuitable for other types of network communication:
* - it waits for at least one network request to start and finish before returning
* - it waits only for request that were issued after it was called. Requests that are
* already in mid-flight will be ignored.
* - the request start and end times are overlapping. If a new request starts a moment
* after the previous one was finished, the wait will be ended in the "interim"
* period.
* @returns a promise that resolves when the wait is done.
*/
waitForAllRequestsFinished() {
let tab = getActiveTab(getMostRecentBrowserWindow());
let target = devtools.TargetFactory.forTab(tab);
let toolbox = gDevTools.getToolbox(target);
let window = toolbox.getCurrentPanel().panelWin;
return new Promise(resolve => {
// Key is the request id, value is a boolean - is request finished or not?
let requests = new Map();
function onRequest(_, id) {
requests.set(id, false);
}
function onTimings(_, id) {
requests.set(id, true);
maybeResolve();
}
function maybeResolve() {
// Have all the requests in the map finished yet?
if (![...requests.values()].every(finished => finished)) {
return;
}
// All requests are done - unsubscribe from events and resolve!
window.off(EVENTS.NETWORK_EVENT, onRequest);
window.off(EVENTS.RECEIVED_EVENT_TIMINGS, onTimings);
resolve();
}
window.on(EVENTS.NETWORK_EVENT, onRequest);
window.on(EVENTS.RECEIVED_EVENT_TIMINGS, onTimings);
});
},
startTest: function(doneCallback, config) {
this._onTestComplete = function (results) {
Profiler.mark("DAMP - end", true);