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

Issue 1708183002: WTF::bind: Properly handle movable objects in bound arguments. (Closed)

Created:
4 years, 10 months ago by Yuta Kitamura
Modified:
4 years, 10 months ago
Reviewers:
haraken, hiroshige, tzik
CC:
blink-reviews, blink-reviews-wtf_chromium.org, chromium-reviews, gavinp+loader_chromium.org, Nate Chapin, loading-reviews_chromium.org, Mikhail, tyoshino+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

WTF::bind: Properly handle movable objects in bound arguments. This patch makes WTF::bind correctly handle movable objects all the way of the bind() call, including wrapping and unwrapping of arguments. With this patch, you can pass move-only objects to bound arguments and they are handled efficiently. The trickiest part is that the arguments are passed across a function template, which is blessed with C++'s universal reference, and a class template, which is not. Because of that, PartBoundFunctionImpl<> must be instantiated with BoundParameters&&, and PartBoundFunctionImpl<> needs to use a correct version of ParamStorageTraits. The unbound parameters are untouched in this patch. CrossThreadCopier isn't changed, either. Therefore threadSafeBind() always forces a copy for bound arguments for now. BUG=565765 R=haraken@chromium.org, hiroshige@chromium.org, tzik@chromium.org Committed: https://crrev.com/fbbd4c94d77ab61145beff792e4adbe6c3239582 Cr-Commit-Position: refs/heads/master@{#377837}

Patch Set 1 #

Total comments: 16

Patch Set 2 : Not using using; use std::decay; add missing #include. #

Patch Set 3 : Cut the unnecessary copy; add more tests. #

Patch Set 4 : Unwrap now returns non-const lref; add moar comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+170 lines, -35 lines) Patch
M third_party/WebKit/Source/core/loader/BeaconLoader.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/Functional.h View 1 2 3 3 chunks +75 lines, -34 lines 0 comments Download
M third_party/WebKit/Source/wtf/FunctionalTest.cpp View 1 2 3 2 chunks +94 lines, -0 lines 0 comments Download

Messages

Total messages: 39 (13 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1708183002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1708183002/1
4 years, 10 months ago (2016-02-18 12:12:21 UTC) #2
Yuta Kitamura
PTAL (I didn't check with Windows so there may be issues in trybots, though...)
4 years, 10 months ago (2016-02-18 12:13:48 UTC) #3
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/175651) win_chromium_x64_rel_ng on ...
4 years, 10 months ago (2016-02-18 12:46:01 UTC) #5
tzik
https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode165 third_party/WebKit/Source/wtf/Functional.h:165: using StorageTraits = ParamStorageTraits<typename std::conditional<std::is_reference<T>::value, typename std::remove_cv<typename std::remove_reference<T>::type>::type, T>::type>; ...
4 years, 10 months ago (2016-02-18 14:27:02 UTC) #6
tzik
https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode64 third_party/WebKit/Source/wtf/Functional.h:64: R operator()(Params... params) Can we use Universal References here? ...
4 years, 10 months ago (2016-02-18 14:49:18 UTC) #7
tzik
https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode165 third_party/WebKit/Source/wtf/Functional.h:165: using StorageTraits = ParamStorageTraits<typename std::conditional<std::is_reference<T>::value, typename std::remove_cv<typename std::remove_reference<T>::type>::type, T>::type>; ...
4 years, 10 months ago (2016-02-18 15:15:33 UTC) #8
dcheng
Drive-by. https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode66 third_party/WebKit/Source/wtf/Functional.h:66: return m_function(std::forward<Params>(params)...); Nit: #include <utility> https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/FunctionalTest.cpp File third_party/WebKit/Source/wtf/FunctionalTest.cpp ...
4 years, 10 months ago (2016-02-18 17:11:13 UTC) #9
Yuta Kitamura
PTAL at PS2 https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode64 third_party/WebKit/Source/wtf/Functional.h:64: R operator()(Params... params) On 2016/02/18 14:49:18, ...
4 years, 10 months ago (2016-02-19 06:59:51 UTC) #12
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1708183002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1708183002/20001
4 years, 10 months ago (2016-02-19 07:00:24 UTC) #13
Yuta Kitamura
https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode115 third_party/WebKit/Source/wtf/Functional.h:115: static T unwrap(StorageType& value) { return std::move(value); } Turned ...
4 years, 10 months ago (2016-02-19 08:02:13 UTC) #14
Yuta Kitamura
https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode115 third_party/WebKit/Source/wtf/Functional.h:115: static T unwrap(StorageType& value) { return std::move(value); } On ...
4 years, 10 months ago (2016-02-19 09:15:37 UTC) #15
Yuta Kitamura
PTAL at PS3, I think I've removed all the necessary copies.
4 years, 10 months ago (2016-02-19 10:07:46 UTC) #18
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1708183002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1708183002/40001
4 years, 10 months ago (2016-02-19 10:08:59 UTC) #19
tzik
https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h File third_party/WebKit/Source/wtf/Functional.h (right): https://codereview.chromium.org/1708183002/diff/1/third_party/WebKit/Source/wtf/Functional.h#newcode64 third_party/WebKit/Source/wtf/Functional.h:64: R operator()(Params... params) On 2016/02/19 06:59:50, Yuta Kitamura wrote: ...
4 years, 10 months ago (2016-02-19 10:42:45 UTC) #20
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_android_rel_ng on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/25781)
4 years, 10 months ago (2016-02-19 14:08:27 UTC) #22
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1708183002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1708183002/60001
4 years, 10 months ago (2016-02-25 08:15:35 UTC) #25
Yuta Kitamura
According to offline discussion, we decided to avoid automatic move-out on unwrap(), so the functor ...
4 years, 10 months ago (2016-02-25 08:23:50 UTC) #26
tzik
lgtm
4 years, 10 months ago (2016-02-25 08:29:46 UTC) #27
haraken
owner LGTM (relying on tzik's one).
4 years, 10 months ago (2016-02-25 09:19:54 UTC) #28
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/179390)
4 years, 10 months ago (2016-02-25 09:48:32 UTC) #30
Yuta Kitamura
I'm landing this now. hiroshige: Pls speak up if you find something concerning even after ...
4 years, 10 months ago (2016-02-26 05:54:02 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1708183002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1708183002/60001
4 years, 10 months ago (2016-02-26 05:54:42 UTC) #33
hiroshige
lgtm.
4 years, 10 months ago (2016-02-26 06:18:44 UTC) #34
hiroshige
lgtm.
4 years, 10 months ago (2016-02-26 06:18:48 UTC) #35
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 10 months ago (2016-02-26 07:07:41 UTC) #37
commit-bot: I haz the power
4 years, 10 months ago (2016-02-26 07:09:00 UTC) #39
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/fbbd4c94d77ab61145beff792e4adbe6c3239582
Cr-Commit-Position: refs/heads/master@{#377837}

Powered by Google App Engine
This is Rietveld 408576698