|
Pass Callback to TaskRunner by value and consume it on invocation
This is a preparation CL for http://crrev.com/2637843002, which replaces
the Callback parameter of TaskRunner::PostTask with OnceCallback.
This one replaces the passed-by-const-ref Callback parameter of
TaskRunner::PostTask() with pass-by-value.
With the pass-by-const-ref manner as the old code does, we can't avoid
leaving a reference to the callback object on the original thread. That
is, the callback object may be destroyed either on the target thread or
the original thread. That's problematic when a non-thread-safe object is
bound to the callback.
Pass-by-value and move() in this CL mitigate the nondeterminism: if the
caller of TaskRunner::PostTask() passes the callback object as rvalue,
TaskRunner::PostTask() leaves no reference on the original thread.
I.e. the reference is not left if the callback is passed directly from
Bind(), or passed with std::move() as below.
task_runner->PostTask(FROM_HERE, base::Bind(&Foo));
base::Closure cb = base::Bind(&Foo);
task_runner->PostTask(FROM_HERE, std::move(cb));
Otherwise, if the caller passes the callback as lvalue, a reference to
the callback is left on the original thread as we do in the previous code.
I.e. a reference is left if the callback is passed from other non-temporary
variable.
base::Closure cb = base::Bind(&Foo);
task_runner->PostTask(FROM_HERE, cb);
This is less controversial part of http://crrev.com/2637843002. This CL
is mainly to land it incrementally.
TBR=shrike@chromium.org
BUG= 704027
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel
Review-Url: https://codereview.chromium.org/2726523002
Cr-Commit-Position: refs/heads/master@{#460288}
Committed: https://chromium.googlesource.com/chromium/src/+/070c8ffb44d04075bd7400691a2325cb6233558a
Total comments: 7
Total comments: 4
Total comments: 7
Total comments: 2
Total comments: 2
Total comments: 2
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+712 lines, -604 lines) |
Patch |
|
M |
base/critical_closure.h
|
View
|
1
|
3 chunks |
+6 lines, -4 lines |
0 comments
|
Download
|
|
M |
base/critical_closure_internal_ios.mm
|
View
|
1
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
base/deferred_sequenced_task_runner.h
|
View
|
|
3 chunks |
+5 lines, -4 lines |
0 comments
|
Download
|
|
M |
base/deferred_sequenced_task_runner.cc
|
View
|
1
2
3
4
5
6
7
8
|
5 chunks |
+25 lines, -24 lines |
0 comments
|
Download
|
|
M |
base/message_loop/incoming_task_queue.h
|
View
|
1
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
base/message_loop/incoming_task_queue.cc
|
View
|
1
|
3 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
|
M |
base/message_loop/message_loop_task_runner.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/message_loop/message_loop_task_runner.cc
|
View
|
1
|
2 chunks |
+8 lines, -4 lines |
0 comments
|
Download
|
|
M |
base/sequenced_task_runner.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/sequenced_task_runner.cc
|
View
|
1
|
1 chunk |
+5 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/task_runner.h
|
View
|
|
2 chunks |
+2 lines, -3 lines |
0 comments
|
Download
|
|
M |
base/task_runner.cc
|
View
|
|
2 chunks |
+5 lines, -5 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/post_task.h
|
View
|
|
4 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/post_task.cc
|
View
|
1
|
3 chunks |
+11 lines, -11 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/scheduler_single_thread_task_runner_manager.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/scheduler_worker_pool_impl.cc
|
View
|
1
2
3
4
5
6
7
8
|
3 chunks |
+7 lines, -6 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/task.h
|
View
|
1
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/task.cc
|
View
|
1
2
3
4
5
6
7
8
9
|
1 chunk |
+5 lines, -3 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/task_scheduler.h
|
View
|
1
2
3
4
5
6
7
8
9
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/task_scheduler/task_scheduler_impl.h
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
base/task_scheduler/task_scheduler_impl.cc
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/test/null_task_runner.h
|
View
|
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/test/null_task_runner.cc
|
View
|
|
1 chunk |
+4 lines, -5 lines |
0 comments
|
Download
|
|
M |
base/test/scoped_task_scheduler.cc
|
View
|
1
|
6 chunks |
+12 lines, -9 lines |
0 comments
|
Download
|
|
M |
base/test/test_mock_time_task_runner.h
|
View
|
1
2
3
4
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/test/test_mock_time_task_runner.cc
|
View
|
1
2
3
4
|
4 chunks |
+14 lines, -8 lines |
0 comments
|
Download
|
|
M |
base/test/test_pending_task.h
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
base/test/test_pending_task.cc
|
View
|
1
|
1 chunk |
+9 lines, -9 lines |
0 comments
|
Download
|
|
M |
base/test/test_simple_task_runner.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/test/test_simple_task_runner.cc
|
View
|
1
2
3
4
|
2 chunks |
+10 lines, -8 lines |
0 comments
|
Download
|
|
M |
base/threading/post_task_and_reply_impl.h
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
base/threading/post_task_and_reply_impl_unittest.cc
|
View
|
1
2
3
4
|
2 chunks |
+4 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/threading/sequenced_worker_pool.h
|
View
|
1
|
6 chunks |
+9 lines, -10 lines |
0 comments
|
Download
|
|
M |
base/threading/sequenced_worker_pool.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
11 chunks |
+48 lines, -47 lines |
0 comments
|
Download
|
|
M |
base/threading/worker_pool.h
|
View
|
|
1 chunk |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
base/threading/worker_pool.cc
|
View
|
|
5 chunks |
+8 lines, -8 lines |
0 comments
|
Download
|
|
M |
base/threading/worker_pool_posix.h
|
View
|
1
|
2 chunks |
+2 lines, -3 lines |
0 comments
|
Download
|
|
M |
base/threading/worker_pool_posix.cc
|
View
|
1
|
5 chunks |
+10 lines, -7 lines |
0 comments
|
Download
|
|
M |
base/threading/worker_pool_win.cc
|
View
|
1
2
3
4
|
2 chunks |
+5 lines, -2 lines |
0 comments
|
Download
|
|
M |
base/trace_event/memory_dump_manager_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
|
3 chunks |
+7 lines, -5 lines |
0 comments
|
Download
|
|
M |
cc/test/ordered_simple_task_runner.h
|
View
|
1
|
3 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
|
M |
cc/test/ordered_simple_task_runner.cc
|
View
|
1
|
4 chunks |
+14 lines, -10 lines |
0 comments
|
Download
|
|
M |
cc/tiles/image_controller.h
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
cc/tiles/image_controller_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
5 chunks |
+13 lines, -10 lines |
0 comments
|
Download
|
|
M |
cc/tiles/tile_manager_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
|
2 chunks |
+6 lines, -4 lines |
0 comments
|
Download
|
|
M |
chrome/browser/after_startup_task_utils.h
|
View
|
1
|
3 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/browser/after_startup_task_utils.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
4 chunks |
+10 lines, -9 lines |
0 comments
|
Download
|
|
M |
chrome/browser/after_startup_task_utils_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
4 chunks |
+10 lines, -7 lines |
0 comments
|
Download
|
|
M |
chrome/browser/chrome_content_browser_client.h
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
chrome/browser/chrome_content_browser_client.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/browser/chromeos/login/users/fake_chrome_user_manager.h
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
M |
chrome/browser/chromeos/login/users/fake_chrome_user_manager.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/browser/chromeos/login/users/mock_user_manager.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/browser/memory/tab_manager_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
6 chunks |
+7 lines, -11 lines |
0 comments
|
Download
|
|
M |
chromecast/base/system_time_change_notifier_unittest.cc
|
View
|
1
|
2 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
|
M |
chromeos/dbus/blocking_method_caller.h
|
View
|
1
|
1 chunk |
+0 lines, -1 line |
0 comments
|
Download
|
|
M |
chromeos/dbus/blocking_method_caller_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
chromeos/tpm/tpm_token_info_getter_unittest.cc
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
components/history/core/browser/history_service.h
|
View
|
1
2
3
4
5
6
7
8
9
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
components/history/core/browser/history_service.cc
|
View
|
1
2
3
4
5
6
7
8
9
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
components/memory_pressure/memory_pressure_monitor_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
4 chunks |
+6 lines, -7 lines |
0 comments
|
Download
|
|
M |
components/subresource_filter/content/browser/content_ruleset_service_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
components/user_manager/fake_user_manager.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/browser/browser_thread_impl.h
|
View
|
1
|
2 chunks |
+16 lines, -6 lines |
0 comments
|
Download
|
|
M |
content/browser/browser_thread_impl.cc
|
View
|
|
6 chunks |
+27 lines, -24 lines |
0 comments
|
Download
|
|
M |
content/browser/compositor/reflector_impl_unittest.cc
|
View
|
1
2
3
4
|
3 chunks |
+5 lines, -3 lines |
0 comments
|
Download
|
|
M |
content/browser/dom_storage/dom_storage_task_runner.h
|
View
|
1
|
4 chunks |
+7 lines, -6 lines |
0 comments
|
Download
|
|
M |
content/browser/dom_storage/dom_storage_task_runner.cc
|
View
|
|
2 chunks |
+9 lines, -8 lines |
0 comments
|
Download
|
|
M |
content/browser/startup_task_runner_unittest.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
10 chunks |
+34 lines, -40 lines |
0 comments
|
Download
|
|
M |
content/child/worker_thread_registry.h
|
View
|
1
|
3 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
content/child/worker_thread_registry.cc
|
View
|
1
2
3
4
5
6
7
|
5 chunks |
+8 lines, -8 lines |
0 comments
|
Download
|
|
M |
content/public/browser/browser_thread.h
|
View
|
|
4 chunks |
+7 lines, -7 lines |
0 comments
|
Download
|
|
M |
content/public/browser/content_browser_client.h
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/public/browser/content_browser_client.cc
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+4 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/public/child/worker_thread.h
|
View
|
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
|
M |
content/renderer/categorized_worker_pool.h
|
View
|
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/renderer/categorized_worker_pool.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
5 chunks |
+9 lines, -10 lines |
0 comments
|
Download
|
|
M |
content/renderer/render_thread_impl_browsertest.cc
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/test/test_blink_web_unit_test_support.cc
|
View
|
1
2
3
4
5
6
7
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
ios/chrome/app/application_delegate/app_state.mm
|
View
|
1
2
3
4
5
6
7
8
9
|
3 chunks |
+6 lines, -3 lines |
0 comments
|
Download
|
|
M |
ios/web/public/web_thread.h
|
View
|
|
3 chunks |
+6 lines, -6 lines |
0 comments
|
Download
|
|
M |
ios/web/web_thread_impl.h
|
View
|
1
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
ios/web/web_thread_impl.cc
|
View
|
|
7 chunks |
+25 lines, -22 lines |
0 comments
|
Download
|
|
M |
media/base/fake_single_thread_task_runner.h
|
View
|
|
1 chunk |
+2 lines, -2 lines |
0 comments
|
Download
|
|
M |
media/base/fake_single_thread_task_runner.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
5 chunks |
+10 lines, -8 lines |
0 comments
|
Download
|
|
M |
media/cast/test/skewed_single_thread_task_runner.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
media/cast/test/skewed_single_thread_task_runner.cc
|
View
|
1
|
3 chunks |
+6 lines, -6 lines |
0 comments
|
Download
|
|
M |
mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc
|
View
|
1
|
4 chunks |
+9 lines, -7 lines |
0 comments
|
Download
|
|
M |
net/quic/test_tools/test_task_runner.h
|
View
|
1
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
net/quic/test_tools/test_task_runner.cc
|
View
|
1
|
2 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
|
M |
remoting/base/auto_thread_task_runner.h
|
View
|
|
1 chunk |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
remoting/base/auto_thread_task_runner.cc
|
View
|
1
|
2 chunks |
+10 lines, -8 lines |
0 comments
|
Download
|
|
M |
remoting/client/plugin/pepper_main_thread_task_runner.h
|
View
|
1
|
3 chunks |
+4 lines, -4 lines |
0 comments
|
Download
|
|
M |
remoting/client/plugin/pepper_main_thread_task_runner.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
4 chunks |
+8 lines, -7 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/WebTaskRunner.h
|
View
|
1
|
2 chunks |
+3 lines, -3 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h
|
View
|
1
2
3
4
|
5 chunks |
+8 lines, -7 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
|
View
|
1
2
3
4
|
9 chunks |
+27 lines, -24 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.cc
|
View
|
|
1 chunk |
+5 lines, -4 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/compositor_worker_scheduler.cc
|
View
|
1
|
2 chunks |
+8 lines, -4 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/scheduler_tqm_delegate_for_test.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/scheduler_tqm_delegate_for_test.cc
|
View
|
|
1 chunk |
+5 lines, -4 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/scheduler_tqm_delegate_impl.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/scheduler_tqm_delegate_impl.cc
|
View
|
|
1 chunk |
+6 lines, -5 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/web_task_runner_impl.h
|
View
|
1
|
2 chunks |
+2 lines, -1 line |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/child/web_task_runner_impl.cc
|
View
|
1
|
2 chunks |
+4 lines, -2 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h
|
View
|
1
2
3
4
|
2 chunks |
+2 lines, -3 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
4 chunks |
+9 lines, -7 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.h
|
View
|
1
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
third_party/WebKit/Source/platform/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.cc
|
View
|
|
1 chunk |
+6 lines, -5 lines |
0 comments
|
Download
|
|
M |
ui/accelerated_widget_mac/window_resize_helper_mac.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
6 chunks |
+11 lines, -10 lines |
0 comments
|
Download
|
Total messages: 161 (98 generated)
|