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

Issue 1496403002: base: Stop using Pass() on move-only types in Bind and Callback. (Closed)

Created:
5 years ago by danakj
Modified:
5 years ago
Reviewers:
Nico, dcheng
CC:
chromium-reviews, piman, tzik, vmpstr+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

base: Stop using Pass() on move-only types in Bind and Callback. This replaces calls to .Pass() with calls to std::move() instead, which will help allow us to remove the .Pass() method off of our move-only types. It does not dis/allow any new behaviour with Bind and Callback. Specifically: 1. PassedWrapper is created from base::Passed. Previously PassedWrapper called .Pass() which required a whitelisted type to compile. Now we get a much nicer error by using enable_if on base::Passed to check that the type is whitelisted: ../../base/callback_unittest.cc:221:66: error: no matching function for call to 'Passed' Callback<void(void)> callback = base::Bind(&TakeUniqueByValue, base::Passed(&i)); ^~~~~~~~~~~~ This prevents use such as base::Passed(&a_std_unique_ptr). 2. The CallbackParamTraits specialize on the whitelist, and for non- whitelisted types it will store a T and pass a const T&. The receiving method will take a T which will try to copy and fail for non-whitelisted move-only types. Secondly, the constructor of BindState will fail as Bind takes a const T& for each bound argument currently, and the storage of T will try to copy into the BindState. This prevents use such as base::Bind(&F, std::unique_ptr<T>()), which will also apply to scoped_ptr. R=Nico, dcheng BUG=557422 Committed: https://crrev.com/314d1f44144e9d2a12d41445c9e5a1287e14373c Cr-Commit-Position: refs/heads/master@{#363635}

Patch Set 1 #

Total comments: 5

Patch Set 2 : bind-pass: less&& #

Patch Set 3 : bind-pass: more&& #

Patch Set 4 : bind-pass: bettercomment #

Total comments: 4

Patch Set 5 : bind-pass: fixes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -20 lines) Patch
M base/bind_helpers.h View 1 2 3 4 4 chunks +30 lines, -17 lines 0 comments Download
M base/callback_internal.h View 3 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 30 (11 generated)
danakj
https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h#newcode375 base/bind_helpers.h:375: explicit PassedWrapper(T&& scoper) This take a T&&, but the ...
5 years ago (2015-12-04 20:46:13 UTC) #1
danakj
https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h#newcode586 base/bind_helpers.h:586: static inline internal::PassedWrapper<T> Passed(T&& scoper) { On 2015/12/04 20:46:13, ...
5 years ago (2015-12-04 20:50:17 UTC) #2
dcheng
https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h#newcode586 base/bind_helpers.h:586: static inline internal::PassedWrapper<T> Passed(T&& scoper) { On 2015/12/04 at ...
5 years ago (2015-12-04 20:59:08 UTC) #3
danakj
https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/1/base/bind_helpers.h#newcode586 base/bind_helpers.h:586: static inline internal::PassedWrapper<T> Passed(T&& scoper) { On 2015/12/04 20:59:08, ...
5 years ago (2015-12-04 21:05:26 UTC) #4
danakj
PTAL
5 years ago (2015-12-04 21:07:06 UTC) #5
dcheng
lgtm https://codereview.chromium.org/1496403002/diff/60001/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/60001/base/bind_helpers.h#newcode580 base/bind_helpers.h:580: // via use of enable_if, and the second ...
5 years ago (2015-12-04 22:07:08 UTC) #6
Nico
lgtm https://codereview.chromium.org/1496403002/diff/60001/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/60001/base/bind_helpers.h#newcode575 base/bind_helpers.h:575: // is best suited for use with the ...
5 years ago (2015-12-04 22:08:16 UTC) #7
danakj
https://codereview.chromium.org/1496403002/diff/60001/base/bind_helpers.h File base/bind_helpers.h (right): https://codereview.chromium.org/1496403002/diff/60001/base/bind_helpers.h#newcode575 base/bind_helpers.h:575: // is best suited for use with the return ...
5 years ago (2015-12-04 22:09:30 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1496403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1496403002/80001
5 years ago (2015-12-04 22:12:11 UTC) #11
commit-bot: I haz the power
Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_dbg/builds/149478) android_chromium_gn_compile_rel on tryserver.chromium.linux (JOB_FAILED, ...
5 years ago (2015-12-04 23:01:09 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1496403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1496403002/80001
5 years ago (2015-12-04 23:20:31 UTC) #15
commit-bot: I haz the power
Try jobs failed on following builders: win_chromium_compile_dbg_ng on tryserver.chromium.win (JOB_TIMED_OUT, no build URL) win_chromium_rel_ng on ...
5 years ago (2015-12-05 00:24:17 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1496403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1496403002/80001
5 years ago (2015-12-05 00:29:56 UTC) #19
commit-bot: I haz the power
Try jobs failed on following builders: win_chromium_compile_dbg_ng on tryserver.chromium.win (JOB_TIMED_OUT, no build URL) win_chromium_rel_ng on ...
5 years ago (2015-12-05 02:42:02 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1496403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1496403002/80001
5 years ago (2015-12-07 18:59:32 UTC) #23
commit-bot: I haz the power
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/145514)
5 years ago (2015-12-07 22:22:56 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1496403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1496403002/80001
5 years ago (2015-12-07 22:29:09 UTC) #27
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years ago (2015-12-08 00:44:48 UTC) #28
commit-bot: I haz the power
5 years ago (2015-12-08 00:47:02 UTC) #30
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/314d1f44144e9d2a12d41445c9e5a1287e14373c
Cr-Commit-Position: refs/heads/master@{#363635}

Powered by Google App Engine
This is Rietveld 408576698