2010-07-30 21:22:57 -07:00
|
|
|
var Cc = Components.classes;
|
|
|
|
var Ci = Components.interfaces;
|
|
|
|
|
2010-07-31 07:06:11 -07:00
|
|
|
let launched, startup, restored;
|
2010-07-31 03:31:31 -07:00
|
|
|
|
|
|
|
let runtime = Cc["@mozilla.org/xre/runtime;1"].getService(Ci.nsIXULRuntime);
|
2010-08-01 02:47:42 -07:00
|
|
|
|
|
|
|
try {
|
|
|
|
displayTimestamp("launched", launched = runtime.launchTimestamp);
|
|
|
|
} catch(x) { }
|
|
|
|
|
2010-07-31 03:31:31 -07:00
|
|
|
displayTimestamp("started", startup = runtime.startupTimestamp);
|
2010-07-31 07:06:11 -07:00
|
|
|
if (launched)
|
|
|
|
displayDuration("started", startup - launched);
|
2010-07-31 03:31:31 -07:00
|
|
|
|
|
|
|
let ss = Cc["@mozilla.org/browser/sessionstartup;1"].getService(Ci.nsISessionStartup);
|
|
|
|
displayTimestamp("restored", restored = ss.restoredTimestamp);
|
|
|
|
displayDuration("restored", restored - startup);
|
|
|
|
|
|
|
|
function displayTimestamp(id, µs)
|
|
|
|
{
|
2010-09-05 13:09:55 -07:00
|
|
|
document.getElementById(id).textContent = formatstamp(µs);
|
2010-07-31 03:31:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function displayDuration(id, µs)
|
|
|
|
{
|
2010-09-05 13:09:55 -07:00
|
|
|
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);
|
2010-09-09 04:57:53 -07:00
|
|
|
var query = db.createStatement("SELECT timestamp, launch, startup, appVersion, appBuild, platformVersion, platformBuild FROM duration");
|
2010-09-05 13:09:55 -07:00
|
|
|
query.executeAsync({
|
|
|
|
handleResult: function(results)
|
|
|
|
{
|
|
|
|
for (let row = results.getNextRow(); row; row = results.getNextRow())
|
|
|
|
{
|
2010-09-09 04:57:53 -07:00
|
|
|
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"))));
|
2010-09-05 13:09:55 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
handleError: function(error)
|
|
|
|
{
|
2010-09-09 04:57:53 -07:00
|
|
|
table.appendChild(tr(td("Error: "+ error.message +" ("+ error.result +")")));
|
2010-09-05 13:09:55 -07:00
|
|
|
},
|
|
|
|
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;
|
2010-07-31 03:31:31 -07:00
|
|
|
}
|