From 2b4fe2d2fb588a0169114ef5125bf81f31f73335 Mon Sep 17 00:00:00 2001 From: Marshall Culpepper Date: Tue, 8 Jan 2013 17:13:32 +0100 Subject: [PATCH] Bug 817821: Part 1 - Communicate update download events better to Gaia. r=fabrice --- b2g/components/UpdatePrompt.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/b2g/components/UpdatePrompt.js b/b2g/components/UpdatePrompt.js index 4118a9721e5..f62d5893d4f 100644 --- a/b2g/components/UpdatePrompt.js +++ b/b2g/components/UpdatePrompt.js @@ -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 });