зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1261152 - Keep the content process alive between tps runs. r=jmaher
MozReview-Commit-ID: 77wW1Y9z62B --HG-- extra : rebase_source : d839cb03cba7786edfafcb585ee3fc7ab183485b
This commit is contained in:
Родитель
b6f80962af
Коммит
e3f9f50b1d
|
@ -7,6 +7,7 @@ Cu.import("resource://gre/modules/Promise.jsm");
|
|||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
Cu.import("resource://gre/modules/RemotePageManager.jsm");
|
||||
|
||||
let aboutNewTabService = Cc["@mozilla.org/browser/aboutnewtab-service;1"]
|
||||
.getService(Ci.nsIAboutNewTabService);
|
||||
|
@ -430,7 +431,13 @@ function test(window) {
|
|||
win.gBrowser.removeAllTabsBut(resultsTab);
|
||||
if (pref)
|
||||
Services.prefs.setBoolPref("browser.tabs.warnOnCloseOtherTabs", pref);
|
||||
Services.obs.notifyObservers(win, 'tabswitch-test-results', JSON.stringify({'times': times, 'urls': testURLs}));
|
||||
|
||||
remotePage.sendAsyncMessage("tabswitch-test-results", {
|
||||
times,
|
||||
urls: testURLs,
|
||||
});
|
||||
|
||||
win.close();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -476,7 +483,8 @@ function shutdown(aData, aReason) {
|
|||
unloadFromWindow(window);
|
||||
}
|
||||
Services.obs.removeObserver(observer, "tabswitch-urlfile");
|
||||
Services.obs.removeObserver(observer, "tabswitch-do-test");
|
||||
|
||||
remotePage.destroy();
|
||||
}
|
||||
|
||||
function handleFile(win, file) {
|
||||
|
@ -510,14 +518,14 @@ function handleFile(win, file) {
|
|||
|
||||
var observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "tabswitch-do-test") {
|
||||
test(aSubject);
|
||||
} else if (aTopic == "tabswitch-urlfile") {
|
||||
if (aTopic == "tabswitch-urlfile") {
|
||||
handleFile(aSubject, aData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var remotePage;
|
||||
|
||||
function startup(aData, aReason) {
|
||||
// Load into any existing windows
|
||||
let list = Services.wm.getEnumerator("navigator:browser");
|
||||
|
@ -531,5 +539,11 @@ function startup(aData, aReason) {
|
|||
Services.wm.addListener(windowListener);
|
||||
|
||||
Services.obs.addObserver(observer, "tabswitch-urlfile", false);
|
||||
Services.obs.addObserver(observer, "tabswitch-do-test", false);
|
||||
|
||||
Services.ppmm.loadProcessScript("chrome://tabswitch/content/tabswitch-content-process.js", true);
|
||||
|
||||
remotePage = new RemotePages("about:tabswitch");
|
||||
remotePage.addMessageListener("tabswitch-do-test", function doTest(msg) {
|
||||
test(msg.target.browser.ownerGlobal);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
const {classes: Cc, utils: Cu, interfaces: Ci} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const CHROME_URI = "chrome://tabswitch/content/test.html";
|
||||
|
||||
class TabSwitchAboutModule {
|
||||
constructor() {
|
||||
this.QueryInterface = XPCOMUtils.generateQI([Ci.nsIAboutModule]);
|
||||
}
|
||||
|
||||
newChannel(aURI, aLoadInfo) {
|
||||
let uri = Services.io.newURI(CHROME_URI, null, null);
|
||||
let chan = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo);
|
||||
chan.originalURI = aURI;
|
||||
return chan;
|
||||
}
|
||||
|
||||
getURIFlags(aURI) {
|
||||
return Ci.nsIAboutModule.ALLOW_SCRIPT |
|
||||
Ci.nsIAboutModule.URI_MUST_LOAD_IN_CHILD;
|
||||
}
|
||||
}
|
||||
|
||||
let factory = XPCOMUtils._getFactory(TabSwitchAboutModule);
|
||||
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
let UUIDGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
||||
|
||||
registrar.registerFactory(UUIDGenerator.generateUUID(), "",
|
||||
"@mozilla.org/network/protocol/about;1?what=tabswitch",
|
||||
factory);
|
|
@ -1,22 +1,13 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
function do_test(override) {
|
||||
if (override || document.location.hash.indexOf("#auto") == 0) {
|
||||
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
|
||||
.rootTreeItem
|
||||
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||
Services.obs.notifyObservers(mainWindow, 'tabswitch-do-test', null);
|
||||
Services.obs.addObserver(function onStartup(aSubject, aTopic, aData) {
|
||||
aSubject.close();
|
||||
var data = JSON.parse(aData);
|
||||
sendAsyncMessage("tabswitch-do-test");
|
||||
addMessageListener("tabswitch-test-results", function onMessage(msg) {
|
||||
let data = msg.data;
|
||||
content.tpRecordTime(data.times.join(','), 0, data.urls.join(','));
|
||||
}, 'tabswitch-test-results', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1 +1 @@
|
|||
% chrome://tabswitch/content/test.html#auto
|
||||
% about:tabswitch#auto
|
||||
|
|
Загрузка…
Ссылка в новой задаче