☠☠ backed out by b9faa176ef67 ☠ ☠ | |
author | Georg Fritzsche <georg.fritzsche@googlemail.com> |
Mon, 11 May 2015 19:40:23 +0200 | |
changeset 243287 | c9c7cf08c7d7a1229f66b6cd0b191305aa9f1fc6 |
parent 243286 | eecb2b1271ca5178028d9c04d48b7aeb2624032f |
child 243288 | 73e107ca87c11ba50f41f72203639340a5c90638 |
push id | 28736 |
push user | cbook@mozilla.com |
push date | Tue, 12 May 2015 10:01:42 +0000 |
treeherder | mozilla-central@0ca37b3cb73d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | rvitillo |
bugs | 1122480 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/content/aboutTelemetry.js +++ b/toolkit/content/aboutTelemetry.js @@ -8,16 +8,17 @@ const Ci = Components.interfaces; const Cc = Components.classes; const Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/TelemetryTimestamps.jsm"); Cu.import("resource://gre/modules/TelemetryController.jsm"); Cu.import("resource://gre/modules/TelemetrySession.jsm"); Cu.import("resource://gre/modules/TelemetryLog.jsm"); +Cu.import("resource://gre/modules/Preferences.jsm"); const Telemetry = Services.telemetry; const bundle = Services.strings.createBundle( "chrome://global/locale/aboutTelemetry.properties"); const brandBundle = Services.strings.createBundle( "chrome://branding/locale/brand.properties"); // Maximum height of a histogram bar (in em for html, in chars for text) @@ -37,40 +38,16 @@ const EOL = "\r\n"; #else const EOL = "\n"; #endif // Cached value of document's RTL mode let documentRTLMode = ""; /** - * Helper function for fetching a config pref - * - * @param aPrefName Name of config pref to fetch. - * @param aDefault Default value to return if pref isn't set. - * @return Value of pref - */ -function getPref(aPrefName, aDefault) { - let result = aDefault; - - try { - let prefType = Services.prefs.getPrefType(aPrefName); - if (prefType == Ci.nsIPrefBranch.PREF_BOOL) { - result = Services.prefs.getBoolPref(aPrefName); - } else if (prefType == Ci.nsIPrefBranch.PREF_STRING) { - result = Services.prefs.getCharPref(aPrefName); - } - } catch (e) { - // Return default if Prefs service throws exception - } - - return result; -} - -/** * Helper function for determining whether the document direction is RTL. * Caches result of check on first invocation. */ function isRTL() { if (!documentRTLMode) documentRTLMode = window.getComputedStyle(document.body).direction; return (documentRTLMode == "rtl"); } @@ -93,17 +70,17 @@ let observer = { /** * Updates the button & text at the top of the page to reflect Telemetry state. */ updatePrefStatus: function updatePrefStatus() { // Notify user whether Telemetry is enabled let enabledElement = document.getElementById("description-enabled"); let disabledElement = document.getElementById("description-disabled"); let toggleElement = document.getElementById("toggle-telemetry"); - if (getPref(PREF_TELEMETRY_ENABLED, false)) { + if (Preferences.get(PREF_TELEMETRY_ENABLED, false)) { enabledElement.classList.remove("hidden"); disabledElement.classList.add("hidden"); toggleElement.innerHTML = this.disableTelemetry; } else { enabledElement.classList.add("hidden"); disabledElement.classList.remove("hidden"); toggleElement.innerHTML = this.enableTelemetry; } @@ -215,17 +192,17 @@ let SlowSQL = { mainThreadTitle: bundle.GetStringFromName("slowSqlMain"), otherThreadTitle: bundle.GetStringFromName("slowSqlOther"), /** * Render slow SQL statistics */ render: function SlowSQL_render() { - let debugSlowSql = getPref(PREF_DEBUG_SLOW_SQL, false); + let debugSlowSql = Preferences.get(PREF_DEBUG_SLOW_SQL, false); let {mainThread, otherThreads} = Telemetry[debugSlowSql ? "debugSlowSQL" : "slowSQL"]; let mainThreadCount = Object.keys(mainThread).length; let otherThreadCount = Object.keys(otherThreads).length; if (mainThreadCount == 0 && otherThreadCount == 0) { return; } @@ -460,17 +437,17 @@ function SymbolicationRequest_handleSymb } }; /** * Send a request to the symbolication server to symbolicate this stack. */ SymbolicationRequest.prototype.fetchSymbols = function SymbolicationRequest_fetchSymbols() { let symbolServerURI = - getPref(PREF_SYMBOL_SERVER_URI, DEFAULT_SYMBOL_SERVER_URI); + Preferences.get(PREF_SYMBOL_SERVER_URI, DEFAULT_SYMBOL_SERVER_URI); let request = {"memoryMap" : this.memoryMap, "stacks" : this.stacks, "version" : 3}; let requestJSON = JSON.stringify(request); this.symbolRequest = new XMLHttpRequest(); this.symbolRequest.open("POST", symbolServerURI, true); this.symbolRequest.setRequestHeader("Content-type", "application/json"); this.symbolRequest.setRequestHeader("Content-length", @@ -956,17 +933,17 @@ function toggleSection(aEvent) { statebox.checked = parentElement.classList.contains("expanded"); } /** * Sets the text of the page header based on a config pref + bundle strings */ function setupPageHeader() { - let serverOwner = getPref(PREF_TELEMETRY_SERVER_OWNER, "Mozilla"); + let serverOwner = Preferences.get(PREF_TELEMETRY_SERVER_OWNER, "Mozilla"); let brandName = brandBundle.GetStringFromName("brandFullName"); let subtitleText = bundle.formatStringFromName( "pageSubtitle", [serverOwner, brandName], 2); let subtitleElement = document.getElementById("page-subtitle"); subtitleElement.appendChild(document.createTextNode(subtitleText)); } @@ -981,18 +958,18 @@ function setupListeners() { window.addEventListener("unload", function unloadHandler(aEvent) { window.removeEventListener("unload", unloadHandler); Services.prefs.removeObserver(PREF_TELEMETRY_ENABLED, observer); }, false); document.getElementById("toggle-telemetry").addEventListener("click", function () { - let value = getPref(PREF_TELEMETRY_ENABLED, false); - Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, !value); + let value = Preferences.get(PREF_TELEMETRY_ENABLED, false); + Preferences.set(PREF_TELEMETRY_ENABLED, !value); }, false); document.getElementById("chrome-hangs-fetch-symbols").addEventListener("click", function () { let hangs = Telemetry.chromeHangs; let req = new SymbolicationRequest("chrome-hangs", ChromeHangs.renderHangHeader, hangs.memoryMap, hangs.stacks);