Bug 2045529 Comment 0 Edit History

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

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 ...
```
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 ...
```
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 ...
```

Back to Bug 2045529 Comment 0