зеркало из https://github.com/mozilla/pjs.git
add support for restarting downloads at different priority levels (background vs. foreground), separate out update and extensions jar manifests for faster development turnaround
This commit is contained in:
Родитель
49db45ad14
Коммит
7527702f5f
|
@ -0,0 +1,13 @@
|
|||
toolkit.jar:
|
||||
% content mozapps %content/mozapps/ xpcnativewrappers=yes
|
||||
* content/mozapps/extensions/extensions.xul (content/extensions.xul)
|
||||
* content/mozapps/extensions/extensions.js (content/extensions.js)
|
||||
* content/mozapps/extensions/extensions.xml (content/extensions.xml)
|
||||
* content/mozapps/extensions/extensions.css (content/extensions.css)
|
||||
* content/mozapps/extensions/update.xul (content/update.xul)
|
||||
* content/mozapps/extensions/update.xml (content/update.xml)
|
||||
* content/mozapps/extensions/update.js (content/update.js)
|
||||
content/mozapps/extensions/update.css (content/update.css)
|
||||
* content/mozapps/extensions/about.xul (content/about.xul)
|
||||
* content/mozapps/extensions/about.js (content/about.js)
|
||||
* content/mozapps/extensions/finalize.xul (content/finalize.xul)
|
|
@ -12,17 +12,6 @@ toolkit.jar:
|
|||
* content/mozapps/downloads/download.xml (downloads/content/download.xml)
|
||||
* content/mozapps/downloads/downloadProperties.xul (downloads/content/downloadProperties.xul)
|
||||
* content/mozapps/downloads/downloadProperties.js (downloads/content/downloadProperties.js)
|
||||
* content/mozapps/extensions/extensions.xul (extensions/content/extensions.xul)
|
||||
* content/mozapps/extensions/extensions.js (extensions/content/extensions.js)
|
||||
* content/mozapps/extensions/extensions.xml (extensions/content/extensions.xml)
|
||||
* content/mozapps/extensions/extensions.css (extensions/content/extensions.css)
|
||||
* content/mozapps/extensions/update.xul (extensions/content/update.xul)
|
||||
* content/mozapps/extensions/update.xml (extensions/content/update.xml)
|
||||
* content/mozapps/extensions/update.js (extensions/content/update.js)
|
||||
content/mozapps/extensions/update.css (extensions/content/update.css)
|
||||
* content/mozapps/extensions/about.xul (extensions/content/about.xul)
|
||||
* content/mozapps/extensions/about.js (extensions/content/about.js)
|
||||
* content/mozapps/extensions/finalize.xul (extensions/content/finalize.xul)
|
||||
* content/mozapps/preferences/actionsshared.js (preferences/actionsshared.js)
|
||||
* content/mozapps/preferences/ocsp.js (preferences/ocsp.js)
|
||||
* content/mozapps/preferences/ocsp.xul (preferences/ocsp.xul)
|
||||
|
@ -35,13 +24,6 @@ toolkit.jar:
|
|||
* content/mozapps/preferences/removemp.xul (preferences/removemp.xul)
|
||||
* content/mozapps/preferences/preferences.css (preferences/preferences.css)
|
||||
* content/mozapps/preferences/preferences.xml (preferences/preferences.xml)
|
||||
content/mozapps/update/updates.css (update/content/updates.css)
|
||||
* content/mozapps/update/updates.xul (update/content/updates.xul)
|
||||
* content/mozapps/update/updates.js (update/content/updates.js)
|
||||
* content/mozapps/update/updates.xml (update/content/updates.xml)
|
||||
* content/mozapps/update/incompatible.xul (update/content/incompatible.xul)
|
||||
* content/mozapps/update/incompatible.js (update/content/incompatible.js)
|
||||
* content/mozapps/update/errors.xul (update/content/errors.xul)
|
||||
* content/mozapps/shared/richview.xml (shared/content/richview.xml)
|
||||
content/mozapps/plugins/pluginInstallerWizard.xul (plugins/content/pluginInstallerWizard.xul)
|
||||
content/mozapps/plugins/pluginInstallerWizard.js (plugins/content/pluginInstallerWizard.js)
|
||||
|
|
|
@ -86,7 +86,7 @@ var gCheckingPage = {
|
|||
* See nsIUpdateCheckListener.idl
|
||||
*/
|
||||
onError: function() {
|
||||
dump("*** UpdateCheckListener: ERROR\n");
|
||||
LOG("UpdateCheckListener: ERROR");
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -112,7 +112,6 @@ var gUpdatesAvailablePage = {
|
|||
[brandName, gUpdates.update.version]);
|
||||
var updateNameElement = document.getElementById("updateName");
|
||||
updateNameElement.value = updateName;
|
||||
dump("*** update = " + gUpdates.update.version + "\n");
|
||||
var displayType = updateStrings.getString("updateType_" + gUpdates.update.type);
|
||||
var updateTypeElement = document.getElementById("updateType");
|
||||
updateTypeElement.setAttribute("type", gUpdates.update.type);
|
||||
|
@ -164,7 +163,8 @@ var gDownloadingPage = {
|
|||
var updates =
|
||||
Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIApplicationUpdateService);
|
||||
updates.downloadUpdate(gUpdates.update);
|
||||
LOG("goats");
|
||||
updates.downloadUpdate(gUpdates.update, false);
|
||||
updates.addDownloadListener(this);
|
||||
|
||||
// Build the UI for previously installed updates
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
toolkit.jar:
|
||||
% content mozapps %content/mozapps/ xpcnativewrappers=yes
|
||||
content/mozapps/update/updates.css (content/updates.css)
|
||||
* content/mozapps/update/updates.xul (content/updates.xul)
|
||||
* content/mozapps/update/updates.js (content/updates.js)
|
||||
* content/mozapps/update/updates.xml (content/updates.xml)
|
||||
* content/mozapps/update/incompatible.xul (content/incompatible.xul)
|
||||
* content/mozapps/update/incompatible.js (content/incompatible.js)
|
||||
* content/mozapps/update/errors.xul (content/errors.xul)
|
|
@ -186,7 +186,7 @@ interface nsIApplicationUpdateService : nsISupports
|
|||
/**
|
||||
*
|
||||
*/
|
||||
void downloadUpdate(in nsIUpdate update);
|
||||
void downloadUpdate(in nsIUpdate update, in boolean background);
|
||||
};
|
||||
|
||||
[scriptable, uuid(0765c92c-6145-4253-9db4-594d8023087e)]
|
||||
|
|
|
@ -77,8 +77,9 @@ const STATE_APPLYING = "applying";
|
|||
const STATE_SUCCEEDED = "succeeded";
|
||||
const STATE_FAILED = "failed";
|
||||
|
||||
const DOWNLOAD_CHUNK_SIZE = 65536;
|
||||
const DOWNLOAD_INTERVAL = 1;
|
||||
const DOWNLOAD_CHUNK_SIZE = 65536;
|
||||
const DOWNLOAD_BACKGROUND_INTERVAL = 1;
|
||||
const DOWNLOAD_FOREGROUND_INTERVAL = 0;
|
||||
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
const nsIUpdateService = Components.interfaces.nsIUpdateService;
|
||||
|
@ -376,14 +377,15 @@ UpdateService.prototype = {
|
|||
switch (topic) {
|
||||
case "app-startup":
|
||||
// Resume fetching...
|
||||
this.downloadUpdate(null);
|
||||
this.downloadUpdate(null, true);
|
||||
break;
|
||||
case "profile-after-change":
|
||||
gOS.removeObserver(this, "profile-after-change");
|
||||
|
||||
// Register a background update check timer
|
||||
var tm = Components.classes["@mozilla.org/updates/timer-manager;1"]
|
||||
.getService(Components.interfaces.nsIUpdateTimerManager);
|
||||
var tm =
|
||||
Components.classes["@mozilla.org/updates/timer-manager;1"]
|
||||
.getService(Components.interfaces.nsIUpdateTimerManager);
|
||||
var interval = getPref("getIntPref", PREF_APP_UPDATE_INTERVAL, 86400000);
|
||||
tm.registerTimer("background-update-timer", this, interval,
|
||||
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||
|
@ -518,7 +520,7 @@ UpdateService.prototype = {
|
|||
prompter.showUpdateAvailable(update);
|
||||
}
|
||||
else
|
||||
this.downloadUpdate(update);
|
||||
this.downloadUpdate(update, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -555,14 +557,17 @@ UpdateService.prototype = {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
downloadUpdate: function(update) {
|
||||
downloadUpdate: function(update, background) {
|
||||
LOG("downloadUpdate");
|
||||
|
||||
if (this._downloader && this._downloader.isBusy) {
|
||||
LOG("no support for downloading more than one update at a time");
|
||||
return;
|
||||
if (background == this._downloader.background) {
|
||||
LOG("no support for downloading more than one update at a time");
|
||||
return;
|
||||
}
|
||||
this._downloader.cancel();
|
||||
}
|
||||
this._downloader = new Downloader();
|
||||
this._downloader = new Downloader(background);
|
||||
this._downloader.downloadUpdate(update);
|
||||
},
|
||||
|
||||
|
@ -791,12 +796,31 @@ Checker.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function Downloader() {
|
||||
/**
|
||||
* Manages the download of updates
|
||||
* @param background
|
||||
* Whether or not this downloader is operating in background
|
||||
* update mode.
|
||||
* @constructor
|
||||
*/
|
||||
function Downloader(background) {
|
||||
this.background = background;
|
||||
}
|
||||
Downloader.prototype = {
|
||||
_patch: null, // UpdatePatch
|
||||
_request: null, // nsIIncrementalDownload
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
cancel: function() {
|
||||
if (this._request &&
|
||||
this._request instanceof Components.interfaces.nsIRequest) {
|
||||
const NS_BINDING_ABORTED = 0x804b0002;
|
||||
this._request.cancel(NS_BINDING_ABORTED);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -1010,6 +1034,7 @@ Downloader.prototype = {
|
|||
* attempt to resume downloading what it was previously downloading.
|
||||
*/
|
||||
downloadUpdate: function(update) {
|
||||
LOG("downloadUpdate");
|
||||
var updateDir = this._getUpdatesDir();
|
||||
|
||||
// This function may return null, which indicates that there are no patches
|
||||
|
@ -1034,7 +1059,9 @@ Downloader.prototype = {
|
|||
LOG("Downloader.downloadUpdate: Downloading from " + uri.spec + " to " +
|
||||
patchFile.path);
|
||||
|
||||
this._request.init(uri, patchFile, DOWNLOAD_CHUNK_SIZE, DOWNLOAD_INTERVAL);
|
||||
var interval = this.background ? DOWNLOAD_BACKGROUND_INTERVAL
|
||||
: DOWNLOAD_FOREGROUND_INTERVAL;
|
||||
this._request.init(uri, patchFile, DOWNLOAD_CHUNK_SIZE, interval);
|
||||
this._request.start(this, null);
|
||||
|
||||
this._writeStatusFile(updateDir, STATE_DOWNLOADING);
|
||||
|
@ -1074,6 +1101,7 @@ Downloader.prototype = {
|
|||
},
|
||||
|
||||
onProgress: function(request, context, progress, maxProgress) {
|
||||
LOG("MODE: " + (this.background ? "BACKGROUND" : "FOREGROUND"));
|
||||
request.QueryInterface(nsIIncrementalDownload);
|
||||
LOG("Downloader.onProgress: " + request.URI.spec + ", " + progress + "/" + maxProgress);
|
||||
var listenerCount = this._listeners.length;
|
||||
|
|
Загрузка…
Ссылка в новой задаче