Skip to content

Instantly share code, notes, and snippets.

@indygreg
Last active Dec 16, 2015
Embed
What would you like to do?
Gecko session recording
For the *current* session, FHR needs the following:
c1) The UTC day the session started
c2) The current total length of the session in seconds
c3) {main, firstPaint, sessionRestored} times (from nsIAppStartup or equivalent)
c4) User activity for this session. Currently this is recorded as a count of the number of user-interaction-active observers that were fired.
For *previous* sessions, FHR needs:
p1) All of the above
p2) Whether the session was cleanly shut down or aborted
Firefox's slow startup notification feature needs:
ss1) One of {main, firstPaint, sessionRestored} for the previous N sessions so it can calculate an average or median and prompt if above a threshold.
There are various non-requirements worth mentioning:
nr1) Persistence of every session for all of time. FHR can periodically poll and copy data into its data store. Alternatively, FHR could not copy data and use the session recorder as source of truth. As long as sessions for previous 180 are available, FHR will be happy.
interface nsIGeckoSession : nsISupports {
// Values from nsIAppStartup. These should be expressed in durations, not in wall clock times.
readonly attribute unsigned int mainTime;
readonly attribute unsigned int firstPaintTime;
readonly attribute unsigned int sessionRestoredTime;
// When the session started and ended, expressed in seconds since UNIX epoch.
readonly attribute unsigned int startTime;
readonly attribute unsigned int endTime;
// How many seconds this session was "active" or "inactive" for. This is a measure of user activity.
readonly attribute unsigned int activeTime;
readonly attribute unsigned int inactiveTime;
// Enumerated values for why the session ended.
// TODO have bsmedberg weigh in here.
// User closed the application.
const unsigned short APP_CLOSED = 1;
// Clean shutdown caused by some other entity (like the OS) forcing app termination.
const unsigned short APP_TERMINATED = 2;
// Gecko crashed.
const unsigned short CRASHED = 3;
// We don't know what happened.
const unsigned short UNKNOWN = 4;
// One of the constants above.
readonly attribute unsigned short endReason;
// Whether the session was cleanly shut down.
readonly attribute boolean isClean;
// TODO consider adding crash info to this interface.
};
interface nsISessionRecorder : nsISupports {
// Obtain the sessions started on or after the specified UNIX time.
// TODO is int the best param type? Is there a date type we should accept?
Enumerable<nsIGeckoSession> getSessionsSince(unsigned int time);
// Obtain sessions active between the specified time range.
Enumerable<nsIGeckoSession> getSessionsBetween(unsigned int begin, unsigned int end);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment