mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
make pause/resume work properly
This commit is contained in:
parent
dcbe2f5e68
commit
ed8394a54b
@ -38,7 +38,7 @@
|
||||
|
||||
<!ENTITY details.link "Details">
|
||||
<!ENTITY pause.label "Pause">
|
||||
<!ENTITY pause.accesskey "P">
|
||||
<!ENTITY pause.accesskey "e">
|
||||
<!ENTITY close.label "Close">
|
||||
<!ENTITY close.accesskey "C">
|
||||
|
||||
|
@ -10,6 +10,8 @@ license404Error=The license file could not be found. Please contact the distribu
|
||||
downloadingLicense=Downloading license text...
|
||||
statusSucceededFormat=Installed on: %S
|
||||
statusFailed=Install Failed
|
||||
pauseButtonPause=Pause
|
||||
pauseButtonResume=Resume
|
||||
# The prefix /update2/0/ uniquely identifies the format of this URL. If you
|
||||
# change the format of this URL, then you MUST change the prefix (i.e.,
|
||||
# increment 0 to 1).
|
||||
|
@ -318,6 +318,7 @@ var gDownloadingPage = {
|
||||
else
|
||||
updates.pauseDownload();
|
||||
this._paused = !this._paused;
|
||||
document.getElementById("activeDownloadItem").paused = this._paused;
|
||||
},
|
||||
|
||||
onClose: function() {
|
||||
@ -361,31 +362,35 @@ var gDownloadingPage = {
|
||||
// Flip the progressmeter back to "undetermined" mode in case we need to
|
||||
// download a new (complete) update patch.
|
||||
var active = document.getElementById("activeDownloadItem");
|
||||
active.stopDownload();
|
||||
|
||||
var state = STATE_FAILED;
|
||||
active.state = gUpdates.update.state;
|
||||
|
||||
const NS_BINDING_ABORTED = 0x804b0002;
|
||||
var updates =
|
||||
Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIApplicationUpdateService);
|
||||
if (status == Components.results.NS_ERROR_UNEXPECTED) {
|
||||
if (!gUpdates.update.isCompleteUpdate) {
|
||||
// If we were downloading a patch and the patch verification phase
|
||||
// failed, log this and then commence downloading the complete update.
|
||||
LOG("Verification of patch failed, downloading complete update");
|
||||
gUpdates.update.isCompleteUpdate = true;
|
||||
state = updates.downloadUpdate(gUpdates.update, false);
|
||||
}
|
||||
if (state == STATE_FAILED)
|
||||
switch (status) {
|
||||
case Components.results.NS_ERROR_UNEXPECTED:
|
||||
LOG("DLP:STATE = " + gUpdates.update.state);
|
||||
if (gUpdates.update.state == STATE_FAILED)
|
||||
this.showVerificationError();
|
||||
else
|
||||
else {
|
||||
// Verification failed for a partial patch, complete patch is now
|
||||
// downloading so return early and do NOT remove the download listener!
|
||||
|
||||
// Reset the progress meter to "undertermined" mode so that we don't
|
||||
// show old progress for the new download of the "complete" patch.
|
||||
active.stopDownload();
|
||||
return;
|
||||
}
|
||||
else if (status == NS_BINDING_ABORTED) {
|
||||
state = gUpdates.update.state;
|
||||
}
|
||||
break;
|
||||
case NS_BINDING_ABORTED:
|
||||
LOG("gDownloadingPage.onStopRequest: Pausing Download");
|
||||
// Return early, do not remove UI listener since the user may resume
|
||||
// downloading again.
|
||||
return;
|
||||
}
|
||||
active.state = state;
|
||||
|
||||
LOG("Removing Listener");
|
||||
var updates =
|
||||
Components.classes["@mozilla.org/updates/update-service;1"].
|
||||
getService(Components.interfaces.nsIApplicationUpdateService);
|
||||
updates.removeDownloadListener(this);
|
||||
},
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
mode="undetermined"/>
|
||||
<xul:hbox align="center">
|
||||
<xul:label class="update-item-status" xbl:inherits="value=status" flex="1" crop="right"/>
|
||||
<xul:button class="update-item-pause" anonid="pause-button"
|
||||
<xul:button class="update-item-pause" anonid="pauseButton"
|
||||
label="&pause.label;" accesskey="&pause.accesskey;"/>
|
||||
</xul:hbox>
|
||||
</xul:vbox>
|
||||
@ -85,6 +85,9 @@
|
||||
<field name="_modeDeck">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "modeDeck");
|
||||
</field>
|
||||
<field name="_pauseButton">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "pauseButton");
|
||||
</field>
|
||||
<method name="setUpdate">
|
||||
<parameter name="update"/>
|
||||
<body><![CDATA[
|
||||
@ -110,6 +113,7 @@
|
||||
<body><![CDATA[
|
||||
if (!this._started) {
|
||||
this._progressBar.setAttribute("mode", "normal");
|
||||
this._pauseButton.disabled = false;
|
||||
this._started = true;
|
||||
}
|
||||
]]></body>
|
||||
@ -119,11 +123,25 @@
|
||||
<body><![CDATA[
|
||||
if (this._started) {
|
||||
this._progressBar.setAttribute("mode", "undetermined");
|
||||
this._pauseButton.disabled = true;
|
||||
this._started = false;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<field name="_paused">false</field>
|
||||
<property name="paused">
|
||||
<getter><![CDATA[
|
||||
return this._paused;
|
||||
]]></getter>
|
||||
<setter><![CDATA[
|
||||
this._paused = val;
|
||||
var key = val ? "pauseButtonResume" : "pauseButtonPause";
|
||||
this._pauseButton.label = this._strings.getString(key);
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
<property name="state">
|
||||
<getter><![CDATA[
|
||||
return this.getAttribute("state");
|
||||
@ -159,7 +177,7 @@
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="command"><![CDATA[
|
||||
if (event.originalTarget.getAttribute("anonid") == "pause-button")
|
||||
if (event.originalTarget.getAttribute("anonid") == "pauseButton")
|
||||
this.fireEvent("pause");
|
||||
]]></handler>
|
||||
</handlers>
|
||||
|
@ -1489,6 +1489,17 @@ Downloader.prototype = {
|
||||
state = STATE_FAILED;
|
||||
// TODO: use more informative error code here
|
||||
status = Components.results.NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (!this._update.isCompleteUpdate) {
|
||||
// If we were downloading a patch and the patch verification phase
|
||||
// failed, log this and then commence downloading the complete update.
|
||||
LOG("Downloader.onStopRequest: Verification of patch failed, downloading complete update");
|
||||
this._update.isCompleteUpdate = true;
|
||||
var rv = this.downloadUpdate(this._update);
|
||||
LOG("US:STATE = " + rv);
|
||||
// This will reset the |.state| property on this._update if a new
|
||||
// download initiates.
|
||||
}
|
||||
}
|
||||
this._writeStatusFile(this._getUpdatesDir(), state);
|
||||
this._update.state = state;
|
||||
|
Loading…
Reference in New Issue
Block a user