зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1376597 Part 2 - Simplify progress bar handling. r=agashlin
Working on the main patch for this bug (part 1), it took me longer than seemed reasonable to understand how the stub installer progress bar worked and to fit the new stage into it. So I thought I would take the opportunity to attempt a refactor and simplify the whole thing. MozReview-Commit-ID: 9INP1Hgfiuq --HG-- extra : rebase_source : 578d0b69482e3ac75eb02d34f5f44a5ba657b08f
This commit is contained in:
Родитель
0d0d82e5dd
Коммит
7e507760bd
|
@ -47,7 +47,6 @@ Var CanWriteToInstallDir
|
|||
Var HasRequiredSpaceAvailable
|
||||
Var IsDownloadFinished
|
||||
Var DownloadSizeBytes
|
||||
Var HalfOfDownload
|
||||
Var DownloadReset
|
||||
Var ExistingTopDir
|
||||
Var SpaceAvailableBytes
|
||||
|
@ -55,10 +54,8 @@ Var InitialInstallDir
|
|||
Var HandleDownload
|
||||
Var CanSetAsDefault
|
||||
Var InstallCounterStep
|
||||
Var InstallStepSize
|
||||
Var InstallTotalSteps
|
||||
Var ProgressCompleted
|
||||
Var ProgressTotal
|
||||
|
||||
Var ExitCode
|
||||
Var FirefoxLaunchCode
|
||||
|
@ -95,7 +92,6 @@ Var ProfileCleanupPromptType
|
|||
Var ProfileCleanupHeaderString
|
||||
Var ProfileCleanupButtonString
|
||||
Var AppLaunchWaitTickCount
|
||||
Var AppLaunchWaitStepSize
|
||||
|
||||
; Uncomment the following to prevent pinging the metrics server when testing
|
||||
; the stub installer
|
||||
|
@ -161,35 +157,19 @@ Var AppLaunchWaitStepSize
|
|||
; Interval for the install timer
|
||||
!define InstallIntervalMS 100
|
||||
|
||||
; The first step for the install progress bar. By starting with a large step
|
||||
; immediate feedback is given to the user.
|
||||
!define InstallProgressFirstStep 20
|
||||
|
||||
; The finish step size to quickly increment the progress bar after the
|
||||
; installation has finished.
|
||||
!define InstallProgressFinishStep 40
|
||||
|
||||
; Number of steps for the install progress.
|
||||
; This might not be enough when installing on a slow network drive so it will
|
||||
; fallback to downloading the full installer if it reaches this number. The size
|
||||
; of the install progress step is increased when the full installer finishes
|
||||
; instead of waiting.
|
||||
; fallback to downloading the full installer if it reaches this number.
|
||||
|
||||
; Approximately 150 seconds with a 100 millisecond timer and a first step of 20
|
||||
; as defined by InstallProgressFirstStep.
|
||||
!define /math InstallCleanTotalSteps ${InstallProgressFirstStep} + 1500
|
||||
; Approximately 150 seconds with a 100 millisecond timer.
|
||||
!define InstallCleanTotalSteps 1500
|
||||
|
||||
; Approximately 165 seconds (minus 0.2 seconds for each file that is removed)
|
||||
; with a 100 millisecond timer and a first step of 20 as defined by
|
||||
; InstallProgressFirstStep .
|
||||
!define /math InstallPaveOverTotalSteps ${InstallProgressFirstStep} + 1800
|
||||
; Approximately 165 seconds with a 100 millisecond timer.
|
||||
!define InstallPaveOverTotalSteps 1650
|
||||
|
||||
; 5 more seconds at the end of the progress bar to wait for the app to launch.
|
||||
!define AppLaunchWaitSteps 500
|
||||
|
||||
; Number of steps per interval to advance the progress bar. Calibrate this based
|
||||
; on how long the progress bar should spend filling up while awaiting app launch.
|
||||
!define AppLaunchWaitStepSizeMultiplier 20
|
||||
; Blurb duty cycle
|
||||
!define BlurbDisplayMS 19500
|
||||
!define BlurbBlankMS 500
|
||||
|
||||
; Interval between checks for the application window and progress bar updates.
|
||||
!define AppLaunchWaitIntervalMS 100
|
||||
|
@ -197,9 +177,12 @@ Var AppLaunchWaitStepSize
|
|||
; Total time to wait for the application to start before just exiting.
|
||||
!define AppLaunchWaitTimeoutMS 10000
|
||||
|
||||
; Blurb duty cycle
|
||||
!define BlurbDisplayMS 19500
|
||||
!define BlurbBlankMS 500
|
||||
; Maximum value of the download/install/launch progress bar, and the end values
|
||||
; for each individual stage.
|
||||
!define PROGRESS_BAR_TOTAL_STEPS 500
|
||||
!define PROGRESS_BAR_DOWNLOAD_END_STEP 300
|
||||
!define PROGRESS_BAR_INSTALL_END_STEP 475
|
||||
!define PROGRESS_BAR_APP_LAUNCH_END_STEP 500
|
||||
|
||||
; Amount of physical memory required for the 64-bit build to be selected (2 GB).
|
||||
; Machines with this or less RAM get the 32-bit build, even with a 64-bit OS.
|
||||
|
@ -563,7 +546,6 @@ Function .onUserAbort
|
|||
${NSD_KillTimer} OnDownload
|
||||
${NSD_KillTimer} CheckInstall
|
||||
${NSD_KillTimer} FinishInstall
|
||||
${NSD_KillTimer} FinishProgressBar
|
||||
${NSD_KillTimer} DisplayDownloadError
|
||||
${NSD_KillTimer} NextBlurb
|
||||
${NSD_KillTimer} ClearBlurb
|
||||
|
@ -904,17 +886,7 @@ FunctionEnd
|
|||
|
||||
Function SetProgressBars
|
||||
SendMessage $Progressbar ${PBM_SETPOS} $ProgressCompleted 0
|
||||
${ITBL3SetProgressValue} "$ProgressCompleted" "$ProgressTotal"
|
||||
FunctionEnd
|
||||
|
||||
Function RemoveFileProgressCallback
|
||||
IntOp $InstallCounterStep $InstallCounterStep + 2
|
||||
System::Int64Op $ProgressCompleted + $InstallStepSize
|
||||
Pop $ProgressCompleted
|
||||
Call SetProgressBars
|
||||
System::Int64Op $ProgressCompleted + $InstallStepSize
|
||||
Pop $ProgressCompleted
|
||||
Call SetProgressBars
|
||||
${ITBL3SetProgressValue} "$ProgressCompleted" "${PROGRESS_BAR_TOTAL_STEPS}"
|
||||
FunctionEnd
|
||||
|
||||
Function NextBlurb
|
||||
|
@ -1020,21 +992,10 @@ Function OnDownload
|
|||
${EndIf}
|
||||
|
||||
StrCpy $DownloadSizeBytes "$4"
|
||||
System::Int64Op $4 / 2
|
||||
Pop $HalfOfDownload
|
||||
System::Int64Op $HalfOfDownload / $InstallTotalSteps
|
||||
Pop $InstallStepSize
|
||||
StrCpy $AppLaunchWaitStepSize $InstallStepSize
|
||||
SendMessage $Progressbar ${PBM_SETMARQUEE} 0 0 ; start=1|stop=0 interval(ms)=+N
|
||||
${RemoveStyle} $Progressbar ${PBS_MARQUEE}
|
||||
System::Int64Op $HalfOfDownload + $DownloadSizeBytes
|
||||
Pop $ProgressTotal
|
||||
System::Int64Op $AppLaunchWaitStepSize * ${AppLaunchWaitSteps}
|
||||
Pop $R0
|
||||
System::Int64Op $ProgressTotal + $R0
|
||||
Pop $ProgressTotal
|
||||
StrCpy $ProgressCompleted 0
|
||||
SendMessage $Progressbar ${PBM_SETRANGE32} $ProgressCompleted $ProgressTotal
|
||||
SendMessage $Progressbar ${PBM_SETRANGE32} $ProgressCompleted ${PROGRESS_BAR_TOTAL_STEPS}
|
||||
${EndIf}
|
||||
|
||||
; Don't update the status until after the download starts
|
||||
|
@ -1062,10 +1023,6 @@ Function OnDownload
|
|||
${If} $2 == 0
|
||||
${NSD_KillTimer} OnDownload
|
||||
StrCpy $IsDownloadFinished "true"
|
||||
; The first step of the install progress bar is determined by the
|
||||
; InstallProgressFirstStep define and provides the user with immediate
|
||||
; feedback.
|
||||
StrCpy $InstallCounterStep "${InstallProgressFirstStep}"
|
||||
System::Call "kernel32::GetTickCount()l .s"
|
||||
Pop $EndDownloadPhaseTickCount
|
||||
|
||||
|
@ -1090,13 +1047,9 @@ Function OnDownload
|
|||
|
||||
; Update the progress bars first in the UI change so they take affect
|
||||
; before other UI changes.
|
||||
StrCpy $ProgressCompleted "$DownloadSizeBytes"
|
||||
Call SetProgressBars
|
||||
System::Int64Op $InstallStepSize * ${InstallProgressFirstStep}
|
||||
Pop $R9
|
||||
System::Int64Op $ProgressCompleted + $R9
|
||||
Pop $ProgressCompleted
|
||||
StrCpy $ProgressCompleted "${PROGRESS_BAR_DOWNLOAD_END_STEP}"
|
||||
Call SetProgressBars
|
||||
|
||||
; Disable the Cancel button during the install
|
||||
GetDlgItem $5 $HWNDPARENT 2
|
||||
EnableWindow $5 0
|
||||
|
@ -1175,8 +1128,7 @@ Function OnDownload
|
|||
${GetShortcutsLogPath} $0
|
||||
Delete "$0"
|
||||
|
||||
GetFunctionAddress $0 RemoveFileProgressCallback
|
||||
${RemovePrecompleteEntries} $0
|
||||
${RemovePrecompleteEntries} "false"
|
||||
|
||||
; Delete the install.log and let the full installer create it. When the
|
||||
; installer closes it we can detect that it has completed.
|
||||
|
@ -1194,12 +1146,11 @@ Function OnDownload
|
|||
Exec "$\"$PLUGINSDIR\download.exe$\" /INI=$PLUGINSDIR\${CONFIG_INI}"
|
||||
${NSD_CreateTimer} CheckInstall ${InstallIntervalMS}
|
||||
${Else}
|
||||
${If} $HalfOfDownload != "true"
|
||||
${AndIf} $3 > $HalfOfDownload
|
||||
StrCpy $HalfOfDownload "true"
|
||||
${EndIf}
|
||||
StrCpy $DownloadedBytes "$3"
|
||||
StrCpy $ProgressCompleted "$DownloadedBytes"
|
||||
System::Int64Op $DownloadedBytes * ${PROGRESS_BAR_DOWNLOAD_END_STEP}
|
||||
Pop $ProgressCompleted
|
||||
System::Int64Op $ProgressCompleted / $DownloadSizeBytes
|
||||
Pop $ProgressCompleted
|
||||
Call SetProgressBars
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
@ -1485,8 +1436,7 @@ Function CheckInstall
|
|||
Return
|
||||
${EndIf}
|
||||
|
||||
System::Int64Op $ProgressCompleted + $InstallStepSize
|
||||
Pop $ProgressCompleted
|
||||
IntOp $ProgressCompleted $ProgressCompleted + 1
|
||||
Call SetProgressBars
|
||||
|
||||
${If} ${FileExists} "$INSTDIR\install.log"
|
||||
|
@ -1509,29 +1459,14 @@ Function CheckInstall
|
|||
Delete "$PLUGINSDIR\${CONFIG_INI}"
|
||||
System::Call "kernel32::GetTickCount()l .s"
|
||||
Pop $EndInstallPhaseTickCount
|
||||
System::Int64Op $InstallStepSize * ${InstallProgressFinishStep}
|
||||
Pop $InstallStepSize
|
||||
${NSD_CreateTimer} FinishInstall ${InstallIntervalMS}
|
||||
Call FinishInstall
|
||||
${EndUnless}
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function FinishInstall
|
||||
; The full installer has completed but the progress bar still needs to finish
|
||||
; so increase the size of the step.
|
||||
IntOp $InstallCounterStep $InstallCounterStep + ${InstallProgressFinishStep}
|
||||
${If} $InstallTotalSteps < $InstallCounterStep
|
||||
StrCpy $InstallCounterStep "$InstallTotalSteps"
|
||||
${EndIf}
|
||||
|
||||
${If} $InstallTotalSteps != $InstallCounterStep
|
||||
System::Int64Op $ProgressCompleted + $InstallStepSize
|
||||
Pop $ProgressCompleted
|
||||
Call SetProgressBars
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
${NSD_KillTimer} FinishInstall
|
||||
StrCpy $ProgressCompleted "${PROGRESS_BAR_INSTALL_END_STEP}"
|
||||
Call SetProgressBars
|
||||
|
||||
${If} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade"
|
||||
Delete "$INSTDIR\${FileMainEXE}"
|
||||
|
@ -1540,21 +1475,6 @@ Function FinishInstall
|
|||
|
||||
StrCpy $ExitCode "${ERR_SUCCESS}"
|
||||
|
||||
StrCpy $InstallCounterStep 0
|
||||
${NSD_CreateTimer} FinishProgressBar ${InstallIntervalMS}
|
||||
FunctionEnd
|
||||
|
||||
Function FinishProgressBar
|
||||
IntOp $InstallCounterStep $InstallCounterStep + 1
|
||||
|
||||
${If} $InstallCounterStep < 10
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
${NSD_KillTimer} FinishProgressBar
|
||||
${NSD_KillTimer} NextBlurb
|
||||
${NSD_KillTimer} ClearBlurb
|
||||
|
||||
Call CopyPostSigningData
|
||||
Call LaunchApp
|
||||
FunctionEnd
|
||||
|
@ -1696,7 +1616,7 @@ Function WaitForAppLaunch
|
|||
${If} $0 <> 0
|
||||
${OrIf} $1 <> 0
|
||||
${NSD_KillTimer} WaitForAppLaunch
|
||||
StrCpy $ProgressCompleted "$ProgressTotal"
|
||||
StrCpy $ProgressCompleted "${PROGRESS_BAR_APP_LAUNCH_END_STEP}"
|
||||
Call SetProgressBars
|
||||
Call SendPing
|
||||
Return
|
||||
|
@ -1711,12 +1631,10 @@ Function WaitForAppLaunch
|
|||
Return
|
||||
${EndIf}
|
||||
|
||||
${If} $AppLaunchWaitTickCount < ${AppLaunchWaitSteps}
|
||||
IntOp $0 $AppLaunchWaitStepSize * ${AppLaunchWaitStepSizeMultiplier}
|
||||
System::Int64Op $ProgressCompleted + $0
|
||||
Pop $ProgressCompleted
|
||||
${If} $ProgressCompleted < ${PROGRESS_BAR_APP_LAUNCH_END_STEP}
|
||||
IntOp $ProgressCompleted $ProgressCompleted + 1
|
||||
Call SetProgressBars
|
||||
${EndIf}
|
||||
Call SetProgressBars
|
||||
FunctionEnd
|
||||
|
||||
Function CopyPostSigningData
|
||||
|
|
Загрузка…
Ссылка в новой задаче