Bug 1365861 - Minor gonk cleanup in nsUpdateService.js. r=mhowell

Removes unused gonk code
Changes use of Array.prototype.indexOf(val) != -1 to Array.prototype.includes(val)
Some very minor indentation and logging cleanup
This commit is contained in:
Robert Strong 2017-05-18 11:33:24 -07:00
Родитель 48524055f0
Коммит 7d35bd00fd
1 изменённых файлов: 5 добавлений и 39 удалений

Просмотреть файл

@ -67,7 +67,6 @@ const FILE_ACTIVE_UPDATE_XML = "active-update.xml";
const FILE_BACKUP_UPDATE_LOG = "backup-update.log"; const FILE_BACKUP_UPDATE_LOG = "backup-update.log";
const FILE_LAST_UPDATE_LOG = "last-update.log"; const FILE_LAST_UPDATE_LOG = "last-update.log";
const FILE_UPDATES_XML = "updates.xml"; const FILE_UPDATES_XML = "updates.xml";
const FILE_UPDATE_LINK = "update.link";
const FILE_UPDATE_LOG = "update.log"; const FILE_UPDATE_LOG = "update.log";
const FILE_UPDATE_MAR = "update.mar"; const FILE_UPDATE_MAR = "update.mar";
const FILE_UPDATE_STATUS = "update.status"; const FILE_UPDATE_STATUS = "update.status";
@ -101,7 +100,6 @@ const SERVICE_COULD_NOT_LOCK_UPDATER = 32;
const SERVICE_INSTALLDIR_ERROR = 33; const SERVICE_INSTALLDIR_ERROR = 33;
const WRITE_ERROR_ACCESS_DENIED = 35; const WRITE_ERROR_ACCESS_DENIED = 35;
const WRITE_ERROR_CALLBACK_APP = 37; const WRITE_ERROR_CALLBACK_APP = 37;
const FILESYSTEM_MOUNT_READWRITE_ERROR = 43;
const SERVICE_COULD_NOT_COPY_UPDATER = 49; const SERVICE_COULD_NOT_COPY_UPDATER = 49;
const SERVICE_STILL_APPLYING_TERMINATED = 50; const SERVICE_STILL_APPLYING_TERMINATED = 50;
const SERVICE_STILL_APPLYING_NO_EXIT_CODE = 51; const SERVICE_STILL_APPLYING_NO_EXIT_CODE = 51;
@ -148,10 +146,6 @@ const SERVICE_ERRORS = [SERVICE_UPDATER_COULD_NOT_BE_STARTED,
// Error codes 80 through 99 are reserved for nsUpdateService.js and are not // Error codes 80 through 99 are reserved for nsUpdateService.js and are not
// defined in common/errors.h // defined in common/errors.h
const FOTA_GENERAL_ERROR = 80;
const FOTA_UNKNOWN_ERROR = 81;
const FOTA_FILE_OPERATION_ERROR = 82;
const FOTA_RECOVERY_ERROR = 83;
const INVALID_UPDATER_STATE_CODE = 98; const INVALID_UPDATER_STATE_CODE = 98;
const INVALID_UPDATER_STATUS_CODE = 99; const INVALID_UPDATER_STATUS_CODE = 99;
@ -190,8 +184,6 @@ const APPID_TO_TOPIC = {
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": "sessionstore-windows-restored", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": "sessionstore-windows-restored",
// SeaMonkey // SeaMonkey
"{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": "sessionstore-windows-restored", "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": "sessionstore-windows-restored",
// Fennec
"{aa3c5121-dab2-40e2-81ca-7ea25febc110}": "sessionstore-windows-restored",
// Thunderbird // Thunderbird
"{3550f703-e582-4d05-9a08-453d09bdfdc6}": "mail-startup-done", "{3550f703-e582-4d05-9a08-453d09bdfdc6}": "mail-startup-done",
// Instantbird // Instantbird
@ -931,26 +923,7 @@ function readStringFromFile(file) {
function handleUpdateFailure(update, errorCode) { function handleUpdateFailure(update, errorCode) {
update.errorCode = parseInt(errorCode); update.errorCode = parseInt(errorCode);
if (update.errorCode == FOTA_GENERAL_ERROR || if (WRITE_ERRORS.includes(update.errorCode)) {
update.errorCode == FOTA_FILE_OPERATION_ERROR ||
update.errorCode == FOTA_RECOVERY_ERROR ||
update.errorCode == FOTA_UNKNOWN_ERROR) {
// In the case of FOTA update errors, don't reset the state to pending. This
// causes the FOTA update path to try again, which is not necessarily what
// we want.
update.statusText = gUpdateBundle.GetStringFromName("statusFailed");
Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt).
showUpdateError(update);
writeStatusFile(getUpdatesDir(), STATE_FAILED + ": " + errorCode);
cleanupActiveUpdate();
return true;
}
// Replace with Array.prototype.includes when it has stabilized.
if (WRITE_ERRORS.indexOf(update.errorCode) != -1 ||
update.errorCode == FILESYSTEM_MOUNT_READWRITE_ERROR) {
Cc["@mozilla.org/updates/update-prompt;1"]. Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt). createInstance(Ci.nsIUpdatePrompt).
showUpdateError(update); showUpdateError(update);
@ -1000,7 +973,7 @@ function handleUpdateFailure(update, errorCode) {
update.QueryInterface(Ci.nsIWritablePropertyBag); update.QueryInterface(Ci.nsIWritablePropertyBag);
update.setProperty("patchingFailed", "elevationFailure"); update.setProperty("patchingFailed", "elevationFailure");
let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. let prompter = Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt); createInstance(Ci.nsIUpdatePrompt);
prompter.showUpdateError(update); prompter.showUpdateError(update);
} else { } else {
writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING); writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING);
@ -1015,8 +988,7 @@ function handleUpdateFailure(update, errorCode) {
Services.prefs.clearUserPref(PREF_APP_UPDATE_CANCELATIONS_OSX); Services.prefs.clearUserPref(PREF_APP_UPDATE_CANCELATIONS_OSX);
} }
// Replace with Array.prototype.includes when it has stabilized. if (SERVICE_ERRORS.includes(update.errorCode)) {
if (SERVICE_ERRORS.indexOf(update.errorCode) != -1) {
var failCount = getPref("getIntPref", var failCount = getPref("getIntPref",
PREF_APP_UPDATE_SERVICE_ERRORS, 0); PREF_APP_UPDATE_SERVICE_ERRORS, 0);
var maxFail = getPref("getIntPref", var maxFail = getPref("getIntPref",
@ -1073,7 +1045,7 @@ function handleFallbackToCompleteUpdate(update, postStaging) {
LOG("handleFallbackToCompleteUpdate - install of complete or " + LOG("handleFallbackToCompleteUpdate - install of complete or " +
"only one patch offered failed. Notifying observers. topic: " + "only one patch offered failed. Notifying observers. topic: " +
"update-error, status: unknown, " + "update-error, status: unknown, " +
"update.patchCount: " + update.patchCount + "update.patchCount: " + update.patchCount + ", " +
"oldType: " + oldType); "oldType: " + oldType);
Services.obs.notifyObservers(update, "update-error", "unknown"); Services.obs.notifyObservers(update, "update-error", "unknown");
} }
@ -3881,14 +3853,8 @@ UpdatePrompt.prototype = {
return; return;
// In some cases, we want to just show a simple alert dialog. // In some cases, we want to just show a simple alert dialog.
// Replace with Array.prototype.includes when it has stabilized.
if (update.state == STATE_FAILED && if (update.state == STATE_FAILED &&
(WRITE_ERRORS.indexOf(update.errorCode) != -1 || WRITE_ERRORS.includes(update.errorCode)) {
update.errorCode == FILESYSTEM_MOUNT_READWRITE_ERROR ||
update.errorCode == FOTA_GENERAL_ERROR ||
update.errorCode == FOTA_FILE_OPERATION_ERROR ||
update.errorCode == FOTA_RECOVERY_ERROR ||
update.errorCode == FOTA_UNKNOWN_ERROR)) {
var title = gUpdateBundle.GetStringFromName("updaterIOErrorTitle"); var title = gUpdateBundle.GetStringFromName("updaterIOErrorTitle");
var text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg", var text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg",
[Services.appinfo.name, [Services.appinfo.name,