[base] Remove NO_THREAD_SAFETY_ANALYSIS from base::Optional

This brings base::Optional inline with absl::optional if we decide
to switch (https://crrev.com/c/1277105) and is the right thing to
do even if we don't (mass disabling TSAN is dangerous).

Introduce base::AutoLockMaybe and base::ReleasableAutoLock (inspired
from matching absl types) to fix existing base::Optional<base::AutoLock>
usage.

google3 differs in philosophy in that they prefer explicit
Acquire()/Release() for such use case but Chromium has a strong
preference for RAII locking everywhere so I think these are preferable.
The difference in philosophy is justifiable by them having had
static-thread-safety-analysis on locks for much longer than us (and thus
the safety guarantees provided by RAII locking aren't necessary there --
we could argue this in Chromium too but that's outside the scope of this
change).

Exposing explicit types instead of supporting these use cases directly
on AutoLock avoids abuse where unnecessary.

TBR=rockot@ (mojo/ side-effects)

Bug: 881875, 831825
Change-Id: I241fcd673deb8470791d759e45c374264081feea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1512302
Reviewed-by: danakj <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Reviewed-by: François Doray <[email protected]>
Reviewed-by: Alex Clarke <[email protected]>
Reviewed-by: Łukasz Anforowicz <[email protected]>
Commit-Queue: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/master@{#642206}
11 files changed