Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: base/test/test_mock_time_task_runner.cc

Issue 2720903002: Fix lack of lock in MTTR::TakePendingTasks() and add a few more safety checks. (Closed)
Patch Set: update dependency Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_mock_time_task_runner.cc
diff --git a/base/test/test_mock_time_task_runner.cc b/base/test/test_mock_time_task_runner.cc
index 5d08976049a77de9fcb093b641aeba7aa67df3d6..f4bd7244b4decc0c2bc66661bd2369fb9c0394e5 100644
--- a/base/test/test_mock_time_task_runner.cc
+++ b/base/test/test_mock_time_task_runner.cc
@@ -197,6 +197,7 @@ std::unique_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const {
}
std::deque<TestPendingTask> TestMockTimeTaskRunner::TakePendingTasks() {
+ AutoLock scoped_lock(tasks_lock_);
std::deque<TestPendingTask> tasks;
while (!tasks_.empty()) {
// It's safe to remove const and consume |task| here, since |task| is not
@@ -266,6 +267,7 @@ void TestMockTimeTaskRunner::OnAfterTaskRun() {
}
void TestMockTimeTaskRunner::ProcessAllTasksNoLaterThan(TimeDelta max_delta) {
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_GE(max_delta, TimeDelta());
// Multiple test task runners can share the same thread for determinism in
@@ -292,6 +294,7 @@ void TestMockTimeTaskRunner::ProcessAllTasksNoLaterThan(TimeDelta max_delta) {
}
void TestMockTimeTaskRunner::ForwardClocksUntilTickTime(TimeTicks later_ticks) {
+ DCHECK(thread_checker_.CalledOnValidThread());
if (later_ticks <= now_ticks_)
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698