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

Issue 2557083002: Run ScopedTaskScheduler tasks synchronously. (Closed)

Created:
4 years ago by fdoray
Modified:
4 years ago
Reviewers:
robliao, gab, sky, dcheng
CC:
chromium-reviews, cbentzel+watch_chromium.org, alemate+watch_chromium.org, sadrul, vmpstr+watch_chromium.org, jam, robliao+watch_chromium.org, achuith+watch_chromium.org, fdoray+watch_chromium.org, oshima+watch_chromium.org, darin-cc_chromium.org, gab+watch_chromium.org, stevenjb+watch_chromium.org, davemoore+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Run ScopedTaskScheduler tasks synchronously. With this CL, tasks posted to the base/task_scheduler/post_task.h API no longer run asynchronously on a dedicated thread. Instead, they are posted to a MessageLoop on the thread where the ScopedTaskScheduler lives and run synchronously when RunLoop::Run/RunUntilIdle() is invoked. This CL also allows usage of the base/task_scheduler/post_task.h API within the scope of a TestBrowserThreadBundle. Benefits of running TaskScheduler tasks synchronously: - Tests are more deterministic. - It is easier to wait for a chain of tasks involving TaskScheduler. E.g.: base::PostTaskAndReplyWithTraits( FROM_HERE, TaskTraits(), Bind(&A), Bind(&B)); base::RunLoop().RunUntilIdle(); // Without this CL, this returns immediately because there // are no pending tasks on the main thread initially. With // this CL, this returns when A and B have run. Note that this CL prevents a TestBrowserThreadBundle or a MessageLoop from being initialized in the scope of a ScopedTaskScheduler. It fixes tests that previously did this. BUG=553459 Committed: https://crrev.com/ad58f8382643800d7107f43c91bd2f9776da4900 Cr-Commit-Position: refs/heads/master@{#439505}

Patch Set 1 #

Patch Set 2 : rebase #

Patch Set 3 : git cl try #

Total comments: 30

Patch Set 4 : CR gab robliao #15-16 #

Patch Set 5 : self-review #

Total comments: 4

Patch Set 6 : CR gab #20 #

Total comments: 8

Patch Set 7 : CR robliao #27 #

Total comments: 4

Patch Set 8 : CR gab #37 #

Total comments: 3

Patch Set 9 : add owners #

Total comments: 10

Patch Set 10 : CR dcheng #53 #

Patch Set 11 : fix linux build error #

Patch Set 12 : rebase #

Patch Set 13 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+576 lines, -62 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
M base/message_loop/message_loop.h View 1 2 3 4 5 6 7 8 9 1 chunk +4 lines, -0 lines 0 comments Download
M base/message_loop/message_loop.cc View 1 2 3 4 5 6 7 8 9 1 chunk +8 lines, -0 lines 0 comments Download
M base/task_scheduler/task_scheduler.h View 1 chunk +0 lines, -4 lines 0 comments Download
M base/task_scheduler/task_scheduler_impl.h View 1 chunk +4 lines, -1 line 0 comments Download
M base/task_scheduler/task_tracker.cc View 1 2 3 1 chunk +8 lines, -0 lines 0 comments Download
M base/test/OWNERS View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M base/test/scoped_task_scheduler.h View 1 2 3 4 5 6 7 8 9 1 chunk +37 lines, -10 lines 0 comments Download
M base/test/scoped_task_scheduler.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +230 lines, -17 lines 0 comments Download
A base/test/scoped_task_scheduler_unittest.cc View 1 2 3 4 1 chunk +252 lines, -0 lines 0 comments Download
M base/threading/sequenced_worker_pool_unittest.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/net/client_cert_store_chromeos_unittest.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M content/public/test/test_browser_thread_bundle.h View 1 2 3 4 3 chunks +22 lines, -25 lines 0 comments Download
M content/public/test/test_browser_thread_bundle.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +6 lines, -0 lines 0 comments Download

Messages

Total messages: 93 (48 generated)
fdoray
PTAL
4 years ago (2016-12-07 19:44:56 UTC) #12
gab
This is awesome :) https://codereview.chromium.org/2557083002/diff/40001/base/task_scheduler/task_tracker.cc File base/task_scheduler/task_tracker.cc (right): https://codereview.chromium.org/2557083002/diff/40001/base/task_scheduler/task_tracker.cc#newcode293 base/task_scheduler/task_tracker.cc:293: // Create |shutdown_event_| to avoid ...
4 years ago (2016-12-08 20:15:45 UTC) #15
robliao
https://codereview.chromium.org/2557083002/diff/40001/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/2557083002/diff/40001/base/message_loop/message_loop.cc#newcode371 base/message_loop/message_loop.cc:371: if (task_runner_) Should we DCHECK here? Seems unexpected to ...
4 years ago (2016-12-09 01:32:54 UTC) #16
fdoray
PTAnL https://codereview.chromium.org/2557083002/diff/40001/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/2557083002/diff/40001/base/message_loop/message_loop.cc#newcode371 base/message_loop/message_loop.cc:371: if (task_runner_) On 2016/12/09 01:32:54, robliao wrote: > ...
4 years ago (2016-12-09 16:26:42 UTC) #19
gab
https://codereview.chromium.org/2557083002/diff/40001/content/public/test/test_browser_thread_bundle.cc File content/public/test/test_browser_thread_bundle.cc (right): https://codereview.chromium.org/2557083002/diff/40001/content/public/test/test_browser_thread_bundle.cc#newcode65 content/public/test/test_browser_thread_bundle.cc:65: : base::test::ScopedTaskScheduler::UI_MAIN_LOOP); On 2016/12/09 16:26:42, fdoray wrote: > On ...
4 years ago (2016-12-09 20:04:17 UTC) #20
fdoray
PTAnL https://codereview.chromium.org/2557083002/diff/40001/content/public/test/test_browser_thread_bundle.cc File content/public/test/test_browser_thread_bundle.cc (right): https://codereview.chromium.org/2557083002/diff/40001/content/public/test/test_browser_thread_bundle.cc#newcode65 content/public/test/test_browser_thread_bundle.cc:65: : base::test::ScopedTaskScheduler::UI_MAIN_LOOP); On 2016/12/09 20:04:17, gab wrote: > ...
4 years ago (2016-12-12 18:18:50 UTC) #22
robliao
lgtm + comments https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler.cc File base/test/scoped_task_scheduler.cc (right): https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler.cc#newcode70 base/test/scoped_task_scheduler.cc:70: // MessageLoop (wasn't handed one). |message_loop_| ...
4 years ago (2016-12-13 03:27:42 UTC) #26
robliao
lgtm + comments
4 years ago (2016-12-13 03:27:44 UTC) #27
fdoray
gab@: PTAL https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler.cc File base/test/scoped_task_scheduler.cc (right): https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler.cc#newcode70 base/test/scoped_task_scheduler.cc:70: // MessageLoop (wasn't handed one). |message_loop_| will ...
4 years ago (2016-12-13 19:14:14 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/120001
4 years ago (2016-12-13 19:15:07 UTC) #33
robliao
https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler_unittest.cc File base/test/scoped_task_scheduler_unittest.cc (right): https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler_unittest.cc#newcode236 base/test/scoped_task_scheduler_unittest.cc:236: Bind([]() { On 2016/12/13 19:14:14, fdoray wrote: > On ...
4 years ago (2016-12-13 19:18:26 UTC) #34
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/325009)
4 years ago (2016-12-13 19:26:25 UTC) #36
gab
lgtm https://codereview.chromium.org/2557083002/diff/120001/base/test/scoped_task_scheduler.h File base/test/scoped_task_scheduler.h (right): https://codereview.chromium.org/2557083002/diff/120001/base/test/scoped_task_scheduler.h#newcode26 base/test/scoped_task_scheduler.h:26: // Continuing here, RunUntilIdle() returns after "A" is ...
4 years ago (2016-12-13 19:56:34 UTC) #37
fdoray
https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler.h File base/test/scoped_task_scheduler.h (right): https://codereview.chromium.org/2557083002/diff/100001/base/test/scoped_task_scheduler.h#newcode43 base/test/scoped_task_scheduler.h:43: // When |scoped_task_scheduler| is destroyed, it runs "D" since ...
4 years ago (2016-12-13 20:38:31 UTC) #38
fdoray
sky@: Please review changes in content/public/test/* danakj@: Please review changes in base/*
4 years ago (2016-12-13 20:40:42 UTC) #40
robliao
https://codereview.chromium.org/2557083002/diff/120001/base/test/scoped_task_scheduler.h File base/test/scoped_task_scheduler.h (right): https://codereview.chromium.org/2557083002/diff/120001/base/test/scoped_task_scheduler.h#newcode26 base/test/scoped_task_scheduler.h:26: // Continuing here, RunUntilIdle() returns after "A" is run. ...
4 years ago (2016-12-13 21:26:37 UTC) #41
gab
https://codereview.chromium.org/2557083002/diff/120001/base/test/scoped_task_scheduler.h File base/test/scoped_task_scheduler.h (right): https://codereview.chromium.org/2557083002/diff/120001/base/test/scoped_task_scheduler.h#newcode26 base/test/scoped_task_scheduler.h:26: // Continuing here, RunUntilIdle() returns after "A" is run. ...
4 years ago (2016-12-13 21:33:54 UTC) #42
sky
LGTM https://codereview.chromium.org/2557083002/diff/140001/content/public/test/test_browser_thread_bundle.cc File content/public/test/test_browser_thread_bundle.cc (right): https://codereview.chromium.org/2557083002/diff/140001/content/public/test/test_browser_thread_bundle.cc#newcode68 content/public/test/test_browser_thread_bundle.cc:68: task_scheduler_.reset( Use MakeUnique if possible (see thread on ...
4 years ago (2016-12-13 23:24:05 UTC) #43
gab
https://codereview.chromium.org/2557083002/diff/140001/content/public/test/test_browser_thread_bundle.cc File content/public/test/test_browser_thread_bundle.cc (right): https://codereview.chromium.org/2557083002/diff/140001/content/public/test/test_browser_thread_bundle.cc#newcode68 content/public/test/test_browser_thread_bundle.cc:68: task_scheduler_.reset( On 2016/12/13 23:24:04, sky wrote: > Use MakeUnique ...
4 years ago (2016-12-14 14:43:17 UTC) #44
gab
Final thought. https://codereview.chromium.org/2557083002/diff/140001/base/test/scoped_task_scheduler.h File base/test/scoped_task_scheduler.h (right): https://codereview.chromium.org/2557083002/diff/140001/base/test/scoped_task_scheduler.h#newcode1 base/test/scoped_task_scheduler.h:1: // Copyright 2016 The Chromium Authors. All ...
4 years ago (2016-12-14 14:58:01 UTC) #46
sky
I don't think there is a hard and fast rules on changes like this. For ...
4 years ago (2016-12-14 16:51:26 UTC) #47
fdoray
On 2016/12/14 16:51:26, sky wrote: > I don't think there is a hard and fast ...
4 years ago (2016-12-14 17:26:14 UTC) #49
fdoray
dcheng@: Please review changes in base/
4 years ago (2016-12-14 17:27:15 UTC) #51
fdoray
dcheng@: Please review changes in base/ Note: These changes were already reviewed by base/task_scheduler OWNERS. ...
4 years ago (2016-12-14 17:28:05 UTC) #52
dcheng
https://codereview.chromium.org/2557083002/diff/160001/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/2557083002/diff/160001/base/message_loop/message_loop.cc#newcode360 base/message_loop/message_loop.cc:360: DCHECK(!task_runner || task_runner->BelongsToCurrentThread()); I would prefer we limit the ...
4 years ago (2016-12-15 06:47:36 UTC) #53
fdoray
dcheng@: PTAnL https://codereview.chromium.org/2557083002/diff/160001/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/2557083002/diff/160001/base/message_loop/message_loop.cc#newcode360 base/message_loop/message_loop.cc:360: DCHECK(!task_runner || task_runner->BelongsToCurrentThread()); On 2016/12/15 06:47:36, dcheng ...
4 years ago (2016-12-15 16:39:32 UTC) #54
gab
https://codereview.chromium.org/2557083002/diff/160001/base/test/scoped_task_scheduler.cc File base/test/scoped_task_scheduler.cc (right): https://codereview.chromium.org/2557083002/diff/160001/base/test/scoped_task_scheduler.cc#newcode175 base/test/scoped_task_scheduler.cc:175: Passed(std::move(task)), sequence_token), On 2016/12/15 06:47:36, dcheng wrote: > I'd ...
4 years ago (2016-12-15 17:56:29 UTC) #55
dcheng
On 2016/12/15 17:56:29, gab wrote: > https://codereview.chromium.org/2557083002/diff/160001/base/test/scoped_task_scheduler.cc > File base/test/scoped_task_scheduler.cc (right): > > https://codereview.chromium.org/2557083002/diff/160001/base/test/scoped_task_scheduler.cc#newcode175 > ...
4 years ago (2016-12-15 19:07:19 UTC) #56
dcheng
lgtm
4 years ago (2016-12-15 19:19:50 UTC) #57
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/180001
4 years ago (2016-12-15 19:20:49 UTC) #60
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_compile_dbg_ng/builds/209970)
4 years ago (2016-12-15 20:19:50 UTC) #62
fdoray
https://codereview.chromium.org/2557083002/diff/160001/base/test/scoped_task_scheduler.cc File base/test/scoped_task_scheduler.cc (right): https://codereview.chromium.org/2557083002/diff/160001/base/test/scoped_task_scheduler.cc#newcode156 base/test/scoped_task_scheduler.cc:156: return std::vector<const HistogramBase*>(); On 2016/12/15 16:39:32, fdoray wrote: > ...
4 years ago (2016-12-15 20:49:33 UTC) #63
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/200001
4 years ago (2016-12-15 20:50:28 UTC) #66
commit-bot: I haz the power
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_swarming_rel/builds/87072)
4 years ago (2016-12-15 22:38:09 UTC) #68
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/200001
4 years ago (2016-12-16 12:57:17 UTC) #70
commit-bot: I haz the power
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_swarming_rel/builds/87549)
4 years ago (2016-12-16 14:47:58 UTC) #72
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/200001
4 years ago (2016-12-16 16:15:42 UTC) #74
commit-bot: I haz the power
Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_swarming_rel/builds/87631)
4 years ago (2016-12-16 18:31:46 UTC) #76
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/200001
4 years ago (2016-12-19 13:06:55 UTC) #78
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/280388)
4 years ago (2016-12-19 13:54:25 UTC) #80
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/220001
4 years ago (2016-12-19 14:45:31 UTC) #83
commit-bot: I haz the power
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linux/builds/280442)
4 years ago (2016-12-19 15:19:43 UTC) #85
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2557083002/240001
4 years ago (2016-12-19 17:08:57 UTC) #88
commit-bot: I haz the power
Committed patchset #13 (id:240001)
4 years ago (2016-12-19 18:07:23 UTC) #91
commit-bot: I haz the power
4 years ago (2016-12-19 18:11:43 UTC) #93
Message was sent while issue was closed.
Patchset 13 (id:??) landed as
https://crrev.com/ad58f8382643800d7107f43c91bd2f9776da4900
Cr-Commit-Position: refs/heads/master@{#439505}

Powered by Google App Engine
This is Rietveld 408576698