Need refcounted adapter for OnceCallback |
||||
Issue description
This is currently a blocker for migrating more Mojo things to use OnceCallback. One example problem snippet:
void FooImpl::DoBar(DoBarCallback callback) {
helper_->Bar(
base::Bind(&FooImpl::OnSuccess, this, std::move(callback)),
base::Bind(&FooImpl::OnFailure, this, std::move(callback)));
}
Full thread for reference: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-mojo/b6Ts_X21dT8
Ideally, it'd be nice to only expose this for Mojo; however, I think we might end up having to expose this more widely =/
We need to figure out what the semantics of this adapter would look like though:
- It needs to be copyable to address this use case
- But then does it make sense to rvalue qualify Run()?
- etc etc
,
Nov 23 2016
,
Jan 9 2017
,
Apr 20 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/faa3495a7a1032e994a62ddb6009b23f2ac5a33c commit faa3495a7a1032e994a62ddb6009b23f2ac5a33c Author: tzik <tzik@chromium.org> Date: Thu Apr 20 12:19:50 2017 Introduce base::IgnoreReuse() to wrap OnceCallback into RepeatingCallback This CL adds base::IgnoreReuse() and applies it to ImportantFileWriter. In some rare case such as ImportantFileWriter, ServiceWorkerStorage, and Mojo stuff, a called-only-once callback object is copied and passed to separate code paths, that blocks OnceCallback migration. base::IgnoreReuse() is a workaround for that by wrapping OnceCallback into a RepeatingCallback, and ignores past-first calls. BUG= 668014 Review-Url: https://codereview.chromium.org/2820993002 Cr-Commit-Position: refs/heads/master@{#465979} [modify] https://crrev.com/faa3495a7a1032e994a62ddb6009b23f2ac5a33c/base/callback_helpers.h [modify] https://crrev.com/faa3495a7a1032e994a62ddb6009b23f2ac5a33c/base/callback_helpers_unittest.cc [modify] https://crrev.com/faa3495a7a1032e994a62ddb6009b23f2ac5a33c/base/files/important_file_writer.cc
,
Apr 21 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by dcheng@chromium.org
, Nov 23 2016