mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 830463 - Download/update notification is showing up late on a weak connection in some cases. r=fabrice
This commit is contained in:
parent
292b4f3c5f
commit
642af08c88
@ -1177,6 +1177,9 @@ this.DOMApplicationRegistry = {
|
||||
? updateSvc.scheduleCustomProfileUpdate(appcacheURI, docURI, aProfileDir)
|
||||
: updateSvc.scheduleAppUpdate(appcacheURI, docURI, aApp.localId, false);
|
||||
|
||||
// initialize the progress to 0 right now
|
||||
aApp.progress = 0;
|
||||
|
||||
// We save the download details for potential further usage like cancelling
|
||||
// it.
|
||||
let download = {
|
||||
@ -2050,6 +2053,13 @@ this.DOMApplicationRegistry = {
|
||||
AppDownloadManager.remove(aApp.manifestURL);
|
||||
}
|
||||
|
||||
function sendProgressEvent() {
|
||||
self.broadcastMessage("Webapps:PackageEvent",
|
||||
{ type: "progress",
|
||||
manifestURL: aApp.manifestURL,
|
||||
app: app });
|
||||
}
|
||||
|
||||
function download() {
|
||||
debug("About to download " + aManifest.fullPackagePath());
|
||||
|
||||
@ -2070,6 +2080,7 @@ this.DOMApplicationRegistry = {
|
||||
);
|
||||
|
||||
let lastProgressTime = 0;
|
||||
|
||||
requestChannel.notificationCallbacks = {
|
||||
QueryInterface: function notifQI(aIID) {
|
||||
if (aIID.equals(Ci.nsISupports) ||
|
||||
@ -2088,10 +2099,7 @@ this.DOMApplicationRegistry = {
|
||||
let now = Date.now();
|
||||
if (now - lastProgressTime > MIN_PROGRESS_EVENT_DELAY) {
|
||||
debug("onProgress: " + aProgress + "/" + aProgressMax);
|
||||
self.broadcastMessage("Webapps:PackageEvent",
|
||||
{ type: "progress",
|
||||
manifestURL: aApp.manifestURL,
|
||||
app: app });
|
||||
sendProgressEvent();
|
||||
lastProgressTime = now;
|
||||
self._saveApps();
|
||||
}
|
||||
@ -2117,6 +2125,9 @@ this.DOMApplicationRegistry = {
|
||||
// installed apps should morph to 'updating'.
|
||||
app.installState = aIsUpdate ? "updating" : "pending";
|
||||
|
||||
// initialize the progress to 0 right now
|
||||
app.progress = 0;
|
||||
|
||||
// Staging the zip in TmpD until all the checks are done.
|
||||
let zipFile = FileUtils.getFile("TmpD",
|
||||
["webapps", id, "application.zip"], true);
|
||||
@ -2327,6 +2338,9 @@ this.DOMApplicationRegistry = {
|
||||
});
|
||||
|
||||
requestChannel.asyncOpen(listener, null);
|
||||
|
||||
// send a first progress event to correctly set the DOM object's properties
|
||||
sendProgressEvent();
|
||||
};
|
||||
|
||||
let deviceStorage = Services.wm.getMostRecentWindow("navigator:browser")
|
||||
@ -2810,18 +2824,30 @@ let AppcacheObserver = function(aApp) {
|
||||
this.app = aApp;
|
||||
this.startStatus = aApp.installState;
|
||||
this.lastProgressTime = 0;
|
||||
// send a first progress event to correctly set the DOM object's properties
|
||||
this._sendProgressEvent();
|
||||
};
|
||||
|
||||
AppcacheObserver.prototype = {
|
||||
// nsIOfflineCacheUpdateObserver implementation
|
||||
_sendProgressEvent: function() {
|
||||
let app = this.app;
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:OfflineCache",
|
||||
{ manifest: app.manifestURL,
|
||||
installState: app.installState,
|
||||
progress: app.progress });
|
||||
},
|
||||
|
||||
updateStateChanged: function appObs_Update(aUpdate, aState) {
|
||||
let mustSave = false;
|
||||
let app = this.app;
|
||||
|
||||
debug("Offline cache state change for " + app.origin + " : " + aState);
|
||||
|
||||
var self = this;
|
||||
let setStatus = function appObs_setStatus(aStatus, aProgress) {
|
||||
debug("Offlinecache setStatus to " + aStatus + " for " + app.origin);
|
||||
debug("Offlinecache setStatus to " + aStatus + " with progress " +
|
||||
aProgress + " for " + app.origin);
|
||||
mustSave = (app.installState != aStatus);
|
||||
app.installState = aStatus;
|
||||
app.progress = aProgress;
|
||||
@ -2829,10 +2855,7 @@ AppcacheObserver.prototype = {
|
||||
app.downloading = false;
|
||||
app.downloadAvailable = false;
|
||||
}
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:OfflineCache",
|
||||
{ manifest: app.manifestURL,
|
||||
installState: app.installState,
|
||||
progress: app.progress });
|
||||
self._sendProgressEvent();
|
||||
}
|
||||
|
||||
let setError = function appObs_setError(aError) {
|
||||
|
Loading…
Reference in New Issue
Block a user