Bug 1928220 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Replace runtime initialization of the IMAP thread sleep intervals with
constexpr values, per the coding style guide's requirement to avoid
globals with runtime initialization.

The NSPR helper PR_MillisecondsToInterval() cannot be used in constant
expressions because it calls PR_TicksPerSecond() at runtime. Since all
supported platforms use 1000 ticks/sec (millisecond resolution), define
kTicksPerSecond as a constexpr and express the sleep times directly in
ticks:

- kImapSleepTime = 60 * kTicksPerSecond (60 s)
- kIdleWait = 2 * kTicksPerSecond (2 s)

Add a MOZ_ASSERT in GlobalInitialization() verifying that
PR_TicksPerSecond() matches the compile-time assumption, so any future
platform deviation fails loudly in debug builds instead of silently
producing wrong sleep durations.
Remove the stopgap MOZ_RUNINIT annotation by making the IMAP wait durations
non-runtime-initialized constants. Store the durations as constexpr
second-based constants and convert them with PR_SecondsToInterval() at the
point of use.

    Keep the 60-second IMAP sleep and two-second IDLE delay as file-level constexpr constants, making the IDLE delay available for reuse.
    Convert the folder message and password waits through the same NSPR helper.

Also remove the unused FallbackToFetchWholeMsg() code left behind by the
nsImapBodyShell removal in Bug 1888569, along with an unused include and macro.
Remove the stopgap MOZ_RUNINIT annotation by making the IMAP wait durations
non-runtime-initialized constants. Store the durations as constexpr
second-based constants and convert them with PR_SecondsToInterval() at the
point of use.

- Keep the 60-second IMAP sleep and two-second IDLE delay as file-level constexpr constants, making the IDLE delay available for reuse.
- Convert the folder message and password waits through the same NSPR helper.

Also remove the unused FallbackToFetchWholeMsg() code left behind by the
nsImapBodyShell removal in Bug 1888569, along with an unused include and macro.

Back to Bug 1928220 Comment 1