Bug 597664 - Add finalURI.spec for the mar file download to the local update xml and log the finalURI.spec along with the original URI.spe. r=dtownsend, a=approval2.0

This commit is contained in:
Robert Strong 2010-09-20 21:42:26 -07:00
parent ea4fc7eacb
commit bab2be3b11
3 changed files with 18 additions and 14 deletions

View File

@ -1451,8 +1451,6 @@ var gDownloadingPage = {
* Additional data
*/
onStartRequest: function(request, context) {
if (request instanceof CoI.nsIIncrementalDownload)
LOG("gDownloadingPage", "onStartRequest - spec: " + request.URI.spec);
// This !paused test is necessary because onStartRequest may fire after
// the download was paused (for those speedy clickers...)
if (this._paused)
@ -1475,8 +1473,6 @@ var gDownloadingPage = {
* The total number of bytes that must be transferred
*/
onProgress: function(request, context, progress, maxProgress) {
LOG("gDownloadingPage", "onProgress - progress: " + progress + "/" +
maxProgress);
let status = this._updateDownloadStatus(progress, maxProgress);
var currentProgress = Math.round(100 * (progress / maxProgress));
@ -1522,8 +1518,6 @@ var gDownloadingPage = {
* Human readable version of |status|
*/
onStatus: function(request, context, status, statusText) {
LOG("gDownloadingPage", "onStatus - status: " + status + ", text: " +
statusText);
this._setStatus(statusText);
},
@ -1537,10 +1531,6 @@ var gDownloadingPage = {
* Status code containing the reason for the cessation.
*/
onStopRequest: function(request, context, status) {
if (request instanceof CoI.nsIIncrementalDownload)
LOG("gDownloadingPage", "onStopRequest - spec: " + request.URI.spec +
", status: " + status);
if (this._downloadProgress.mode != "normal")
this._downloadProgress.mode = "normal";

View File

@ -50,7 +50,7 @@ interface nsIXMLHttpRequest;
* be downloaded and applied to a version of this application so that it
* can be updated.
*/
[scriptable, uuid(56863a67-bd69-42de-9f40-583e625b457d)]
[scriptable, uuid(60523512-bb69-417c-9b2c-87a0664b0bbe)]
interface nsIUpdatePatch : nsISupports
{
/**
@ -66,6 +66,11 @@ interface nsIUpdatePatch : nsISupports
*/
attribute AString URL;
/**
* The final URL this patch was being downloaded from
*/
attribute AString finalURL;
/**
* The hash function to use when determining this file's integrity
*/

View File

@ -723,6 +723,9 @@ UpdatePatch.prototype = {
var patch = updates.createElementNS(URI_UPDATE_NS, "patch");
patch.setAttribute("type", this.type);
patch.setAttribute("URL", this.URL);
// finalURL is not available until after the download has started
if (this.finalURL)
patch.setAttribute("finalURL", this.finalURL);
patch.setAttribute("hashFunction", this.hashFunction);
patch.setAttribute("hashValue", this.hashValue);
patch.setAttribute("size", this.size);
@ -2529,7 +2532,13 @@ Downloader.prototype = {
*/
onStartRequest: function Downloader_onStartRequest(request, context) {
if (request instanceof Ci.nsIIncrementalDownload)
LOG("Downloader:onStartRequest - spec: " + request.URI.spec);
LOG("Downloader:onStartRequest - original URI spec: " + request.URI.spec +
", final URI spec: " + request.finalURI.spec);
// Always set finalURL in onStartRequest since it can change.
this._patch.finalURL = request.finalURI.spec;
var um = Cc["@mozilla.org/updates/update-manager;1"].
getService(Ci.nsIUpdateManager);
um.saveUpdates();
var listenerCount = this._listeners.length;
for (var i = 0; i < listenerCount; ++i)
@ -2593,8 +2602,8 @@ Downloader.prototype = {
*/
onStopRequest: function Downloader_onStopRequest(request, context, status) {
if (request instanceof Ci.nsIIncrementalDownload)
LOG("Downloader:onStopRequest - spec: " + request.URI.spec +
", status: " + status);
LOG("Downloader:onStopRequest - original URI spec: " + request.URI.spec +
", final URI spec: " + request.finalURI.spec + ", status: " + status);
var state = this._patch.state;
var shouldShowPrompt = false;