Commit 0cb8577f authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[ScopedTaskEnvironment] Add thread annotations to MockTimeDomain::now_ticks_

As a follow-up to
https://chromium-review.googlesource.com/c/chromium/src/+/1686776/14/base/test/scoped_task_environment.cc#366

Doing so I realized that a thread_annotations bug I'd also hit in
TaskTracker is OS_NACL specific. Fixed in
https://chromium-review.googlesource.com/c/chromium/src/+/1695681
and re-enabling proper safety checks in TaskTracker here.

R=alexclarke@chromium.org

Bug: 946657, 982423
Change-Id: Ibbee23cd855f9c124bb41dfd8d2381b03a020132
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692826
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarAlex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676063}
parent 3f9cf95a
...@@ -341,9 +341,7 @@ void TaskTracker::StartShutdown() { ...@@ -341,9 +341,7 @@ void TaskTracker::StartShutdown() {
} }
} }
// TODO(gab): Figure out why TS_UNCHECKED_READ is insufficient to make thread void TaskTracker::CompleteShutdown() {
// analysis of |shutdown_event_| happy on POSIX.
void TaskTracker::CompleteShutdown() NO_THREAD_SAFETY_ANALYSIS {
// It is safe to access |shutdown_event_| without holding |lock_| because the // It is safe to access |shutdown_event_| without holding |lock_| because the
// pointer never changes after being set by StartShutdown(), which must be // pointer never changes after being set by StartShutdown(), which must be
// called before this. // called before this.
......
...@@ -217,8 +217,9 @@ class ScopedTaskEnvironment::MockTimeDomain ...@@ -217,8 +217,9 @@ class ScopedTaskEnvironment::MockTimeDomain
if (!run_time) if (!run_time)
return base::nullopt; return base::nullopt;
// Check if we have a task that should be running now. // Check if we have a task that should be running now. Reading |now_ticks_|
if (run_time <= now_ticks_) // from the main thread doesn't require the lock.
if (run_time <= TS_UNCHECKED_READ(now_ticks_))
return base::TimeDelta(); return base::TimeDelta();
// The next task is a future delayed task. Since we're using mock time, we // The next task is a future delayed task. Since we're using mock time, we
...@@ -293,7 +294,8 @@ class ScopedTaskEnvironment::MockTimeDomain ...@@ -293,7 +294,8 @@ class ScopedTaskEnvironment::MockTimeDomain
// Only ever written to from the main sequence. Start from real Now() instead // Only ever written to from the main sequence. Start from real Now() instead
// of zero to give a more realistic view to tests. // of zero to give a more realistic view to tests.
TimeTicks now_ticks_{base::subtle::TimeTicksNowIgnoringOverride()}; TimeTicks now_ticks_ GUARDED_BY(now_ticks_lock_){
base::subtle::TimeTicksNowIgnoringOverride()};
}; };
ScopedTaskEnvironment::MockTimeDomain* ScopedTaskEnvironment::MockTimeDomain*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment