зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1366917 - Include the system's RAM in the %SYSTEM_CAPABILITIES% value of the update URL. r=mhowell
This commit is contained in:
Родитель
f150e4d3c9
Коммит
4b949ce27c
|
@ -68,7 +68,7 @@ this.UpdateUtils = {
|
|||
url = url.replace(/%BUILD_ID%/g, Services.appinfo.appBuildID);
|
||||
url = url.replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + this.ABI);
|
||||
url = url.replace(/%OS_VERSION%/g, this.OSVersion);
|
||||
url = url.replace(/%SYSTEM_CAPABILITIES%/g, gSystemCapabilities);
|
||||
url = url.replace(/%SYSTEM_CAPABILITIES%/g, getSystemCapabilities());
|
||||
if (/%LOCALE%/.test(url)) {
|
||||
url = url.replace(/%LOCALE%/g, this.Locale);
|
||||
}
|
||||
|
@ -119,10 +119,32 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "Locale", function() {
|
|||
return null;
|
||||
});
|
||||
|
||||
function getSystemCapabilities() {
|
||||
return gInstructionSet + "," + getMemoryMB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides adhoc system capability information for application update.
|
||||
* Gets the RAM size in megabytes. This will round the value because sysinfo
|
||||
* doesn't always provide RAM in multiples of 1024.
|
||||
*/
|
||||
XPCOMUtils.defineLazyGetter(this, "gSystemCapabilities", function aus_gSC() {
|
||||
function getMemoryMB() {
|
||||
let memoryMB = "unknown";
|
||||
try {
|
||||
memoryMB = Services.sysinfo.getProperty("memsize");
|
||||
if (memoryMB) {
|
||||
memoryMB = Math.round(memoryMB / 1024 / 1024);
|
||||
}
|
||||
} catch (e) {
|
||||
Cu.reportError("Error getting system info memsize property. " +
|
||||
"Exception: " + e);
|
||||
}
|
||||
return memoryMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the supported CPU instruction set.
|
||||
*/
|
||||
XPCOMUtils.defineLazyGetter(this, "gInstructionSet", function aus_gIS() {
|
||||
if (AppConstants.platform == "win") {
|
||||
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
|
||||
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
|
||||
|
|
|
@ -129,9 +129,8 @@ function getProcArchitecture() {
|
|||
}
|
||||
}
|
||||
|
||||
// Provides system capability information for application update though it may
|
||||
// be used by other consumers.
|
||||
function getSystemCapabilities() {
|
||||
// Gets the supported CPU instruction set.
|
||||
function getInstructionSet() {
|
||||
if (AppConstants.platform == "win") {
|
||||
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
|
||||
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
|
||||
|
@ -166,6 +165,21 @@ function getSystemCapabilities() {
|
|||
return "NA";
|
||||
}
|
||||
|
||||
// Gets the RAM size in megabytes. This will round the value because sysinfo
|
||||
// doesn't always provide RAM in multiples of 1024.
|
||||
function getMemoryMB() {
|
||||
let memoryMB = "unknown";
|
||||
try {
|
||||
memoryMB = Services.sysinfo.getProperty("memsize");
|
||||
if (memoryMB) {
|
||||
memoryMB = Math.round(memoryMB / 1024 / 1024);
|
||||
}
|
||||
} catch (e) {
|
||||
do_throw("Error getting system info memsize property. Exception: " + e);
|
||||
}
|
||||
return memoryMB;
|
||||
}
|
||||
|
||||
// Helper function for formatting a url and getting the result we're
|
||||
// interested in
|
||||
function getResult(url) {
|
||||
|
@ -331,6 +345,7 @@ add_task(function* test_custom() {
|
|||
// url constructed with %SYSTEM_CAPABILITIES%
|
||||
add_task(function* test_systemCapabilities() {
|
||||
let url = URL_PREFIX + "%SYSTEM_CAPABILITIES%/";
|
||||
Assert.equal(getResult(url), getSystemCapabilities(),
|
||||
let systemCapabilities = getInstructionSet() + "," + getMemoryMB();
|
||||
Assert.equal(getResult(url), systemCapabilities,
|
||||
"the url param for %SYSTEM_CAPABILITIES%" + MSG_SHOULD_EQUAL);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче