Bug 817821: Part 1 - Communicate update download events better to Gaia. r=fabrice

This commit is contained in:
Marshall Culpepper 2013-01-08 17:13:32 +01:00
parent d9b9fc0db3
commit 2b4fe2d2fb

View File

@ -460,11 +460,20 @@ UpdatePrompt.prototype = {
// nsIRequestObserver
_startedSent: false,
onStartRequest: function UP_onStartRequest(aRequest, aContext) {
this.sendChromeEvent("update-downloading");
// Wait until onProgress to send the update-download-started event, in case
// this request turns out to fail for some reason
this._startedSent = false;
},
onStopRequest: function UP_onStopRequest(aRequest, aContext, aStatusCode) {
let paused = !Components.isSuccessCode(aStatusCode);
this.sendChromeEvent("update-download-stopped", {
paused: paused
});
Services.aus.removeDownloadListener(this);
},
@ -472,7 +481,14 @@ UpdatePrompt.prototype = {
onProgress: function UP_onProgress(aRequest, aContext, aProgress,
aProgressMax) {
this.sendChromeEvent("update-progress", {
if (!this._startedSent) {
this.sendChromeEvent("update-download-started", {
total: aProgressMax
});
this._startedSent = true;
}
this.sendChromeEvent("update-download-progress", {
progress: aProgress,
total: aProgressMax
});