Commit 51d2d911 authored by Doug Thayer's avatar Doug Thayer
Browse files

Bug 1542833 - Collect cold startup scalar r=chutten,florian

Differential Revision: https://phabricator.services.mozilla.com/D27953

--HG--
extra : moz-landing-system : lando
parent 21210ed5
......@@ -1254,6 +1254,24 @@ BrowserGlue.prototype = {
} catch (ex) {}
},
_collectStartupConditionsTelemetry() {
let nowSeconds = Math.round(Date.now() / 1000);
// Don't include cases where we don't have the pref. This rules out the first install
// as well as the first run of a build since this was introduced. These could by some
// definitions be referred to as "cold" startups, but probably not since we likely
// just wrote many of the files we use to disk. This way we should approximate a lower
// bound to the number of cold startups rather than an upper bound.
let lastCheckSeconds = Services.prefs.getIntPref("browser.startup.lastColdStartupCheck", nowSeconds);
Services.prefs.setIntPref("browser.startup.lastColdStartupCheck", nowSeconds);
try {
let secondsSinceLastOSRestart = Services.startup.secondsSinceLastOSRestart;
let isColdStartup = nowSeconds - secondsSinceLastOSRestart > lastCheckSeconds;
Services.telemetry.scalarSet("startup.is_cold", isColdStartup);
} catch (ex) {
Cu.reportError(ex);
}
},
// the first browser window has finished initializing
_onFirstWindowLoaded: function BG__onFirstWindowLoaded(aWindow) {
TabCrashHandler.init();
......@@ -1329,6 +1347,8 @@ BrowserGlue.prototype = {
this._firstWindowTelemetry(aWindow);
this._firstWindowLoaded();
this._collectStartupConditionsTelemetry();
// Set the default favicon size for UI views that use the page-icon protocol.
PlacesUtils.favicons.setDefaultIconURIPreferredSize(16 * aWindow.devicePixelRatio);
this._setPrefExpectations();
......
......@@ -47,6 +47,10 @@
#if defined(XP_WIN)
// Prevent collisions with nsAppStartup::GetStartupInfo()
# undef GetStartupInfo
# include <windows.h>
#elif defined(XP_DARWIN)
# include <mach/mach_time.h>
#endif
#include "mozilla/IOInterposer.h"
......@@ -60,6 +64,8 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#define kPrefRecentCrashes "toolkit.startup.recent_crashes"
#define kPrefAlwaysUseSafeMode "toolkit.startup.always_use_safe_mode"
#define kNanosecondsPerSecond 1000000000.0
#if defined(XP_WIN)
# include "mozilla/perfprobe.h"
/**
......@@ -541,6 +547,25 @@ nsAppStartup::GetWasRestarted(bool *aResult) {
return NS_OK;
}
NS_IMETHODIMP
nsAppStartup::GetSecondsSinceLastOSRestart(int64_t *aResult) {
#if defined(XP_WIN)
*aResult = int64_t(GetTickCount64() / 1000ull);
return NS_OK;
#elif defined(XP_DARWIN)
uint64_t absTime = mach_absolute_time();
mach_timebase_info_data_t timebaseInfo;
mach_timebase_info(&timebaseInfo);
double toNanoseconds =
double(timebaseInfo.numer) / double(timebaseInfo.denom);
*aResult =
std::llround(double(absTime) * toNanoseconds / kNanosecondsPerSecond);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
NS_IMETHODIMP
nsAppStartup::SetInterrupted(bool aInterrupted) {
mInterrupted = aInterrupted;
......
......@@ -156,6 +156,11 @@ interface nsIAppStartup : nsISupports
*/
readonly attribute boolean wasRestarted;
/**
* The number of seconds since the OS was last rebooted
*/
readonly attribute int64_t secondsSinceLastOSRestart;
/**
* Returns an object with main, process, firstPaint, sessionRestored properties.
* Properties may not be available depending on platform or application
......
......@@ -3589,6 +3589,20 @@ startup:
record_in_processes:
- main
is_cold:
bug_numbers:
- 1542833
description: >
Whether or not this startup is the first startup since OS reboot (according to our
best guess.)
expires: never
kind: boolean
notification_emails:
- dothayer@mozilla.com
release_channel_collection: opt-out
record_in_processes:
- 'main'
script.preloader:
mainthread_recompile:
bug_numbers:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment