Closed Bug 2045529 Opened 23 hours ago Closed 11 hours ago

Make the assertion+check less weird in IdleTaskRunner::ResetTimer

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: jstutte, Assigned: jstutte)

References

Details

Attachments

(1 file)

Comment + assertion + equivalent check here:

    // We rely on timers that target the main thread to be infallible (except
    // for very late shutdown edge cases that should not occur, normally).
    nsresult rv = mTimer->InitWithNamedFuncCallback(
        TimedOut, this, aDelay.ToMilliseconds(), nsITimer::TYPE_ONE_SHOT,
        mName);
    if (NS_WARN_IF(NS_FAILED(rv))) {
      MOZ_ASSERT(
          AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads));
      if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) {
        Cancel();
      }
    } else ...

look a bit confusing. Maybe the following would make the intention easier to follow:

    nsresult rv = mTimer->InitWithNamedFuncCallback(
        TimedOut, this, aDelay.ToMilliseconds(), nsITimer::TYPE_ONE_SHOT,
        mName);
    if (NS_WARN_IF(NS_FAILED(rv))) {
      if (AppShutdown::IsInOrBeyond(ShutdownPhase::XPCOMShutdownThreads)) {
        Cancel();
      } else {
        MOZ_ASSERT_UNREACHABLE("We rely on timers that target the main thread to be infallible before shutdown.");
      }
    } else ...

Replace the redundant MOZ_ASSERT + duplicate IsInOrBeyond check with a
cleaner if/else: call Cancel() in the shutdown case, and use
MOZ_ASSERT_UNREACHABLE in the impossible non-shutdown case.

Assignee: nobody → jstutte
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 11 hours ago
Resolution: --- → FIXED
Target Milestone: --- → 153 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: