New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 668014 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 554299



Sign in to add a comment

Need refcounted adapter for OnceCallback

Project Member Reported by dcheng@chromium.org, Nov 23 2016

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
 

Comment 1 by dcheng@chromium.org, Nov 23 2016

Labels: -Pri-3 Pri-2

Comment 2 by ajha@chromium.org, Nov 23 2016

Components: Internals>Mojo
Components: -Internals>Mojo Internals>Mojo>Bindings
Project Member

Comment 4 by bugdroid1@chromium.org, 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

Comment 5 by tzik@chromium.org, Apr 21 2017

Owner: tzik@chromium.org
Status: Fixed (was: Available)

Sign in to add a comment