gecko/toolkit/content/aboutStartup.js
Daniel Brooks 97ac2fce7f about:startup - move UI files to toolkit
--HG--
rename : browser/base/content/aboutStartup.js => toolkit/content/aboutStartup.js
rename : browser/base/content/aboutStartup.xhtml => toolkit/content/aboutStartup.xhtml
rename : browser/locales/en-US/chrome/browser/aboutStartup.dtd => toolkit/locales/en-US/chrome/global/aboutStartup.dtd
rename : browser/locales/en-US/chrome/browser/aboutStartup.properties => toolkit/locales/en-US/chrome/global/aboutStartup.properties
2010-09-09 20:14:56 -04:00

86 lines
2.7 KiB
JavaScript
Executable File

var Cc = Components.classes;
var Ci = Components.interfaces;
let launched, startup, restored;
let runtime = Cc["@mozilla.org/xre/runtime;1"].getService(Ci.nsIXULRuntime);
try {
displayTimestamp("launched", launched = runtime.launchTimestamp);
} catch(x) { }
displayTimestamp("started", startup = runtime.startupTimestamp);
if (launched)
displayDuration("started", startup - launched);
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].getService(Ci.nsISessionStartup);
displayTimestamp("restored", restored = ss.restoredTimestamp);
displayDuration("restored", restored - startup);
function displayTimestamp(id, µs)
{
document.getElementById(id).textContent = formatstamp(µs);
}
function displayDuration(id, µs)
{
document.getElementById(id).nextSibling.textContent = formatµs(µs);
}
function formatstamp(µs)
{
return new Date(µs/1000) +" ("+ formatµs(µs) +")";
}
function formatµs(µs)
{
return µs + " µs";
}
var table = document.getElementsByTagName("table")[1];
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsIFile);
file.append("startup.sqlite");
var svc = Components.classes["@mozilla.org/storage/service;1"]
.getService(Components.interfaces.mozIStorageService);
var db = svc.openDatabase(file);
var query = db.createStatement("SELECT timestamp, launch, startup, appVersion, appBuild, platformVersion, platformBuild FROM duration");
query.executeAsync({
handleResult: function(results)
{
for (let row = results.getNextRow(); row; row = results.getNextRow())
{
table.appendChild(tr(td(formatstamp(row.getResultByName("timestamp"))),
td(formatµs(l = row.getResultByName("launch"))),
td(formatµs(s = row.getResultByName("startup"))),
td(formatµs(l + s)),
td(row.getResultByName("appVersion")),
td(row.getResultByName("appBuild")),
td(row.getResultByName("platformVersion")),
td(row.getResultByName("platformBuild"))));
}
},
handleError: function(error)
{
table.appendChild(tr(td("Error: "+ error.message +" ("+ error.result +")")));
},
handleCompletion: function() { },
});
function td(str)
{
let cell = document.createElement("td");
cell.innerHTML = str;
return cell;
}
function tr()
{
let row = document.createElement("tr");
Array.forEach(arguments, function(cell) { row.appendChild(cell); });
return row;
}