This CL adds SplitOnceCallback, a utility function that allows to get
two OnceCallbacks out of one. Invoking any of the two split callbacks
will run the originally passed callback. Invoking the remaining callback
will result in a no-op.
Bug: 1156809
Change-Id: Iebf4542732fb6230af92fa27c4d7c5705933ad6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586688
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838267}
* Explicit deletion of copy constructors not necessary when move
constructors are given.
* No way to check if the runner had a closure inside.
* RunAndReset() crashed if called with no closure inside.
* operator=() failed to run the outgoing closure.
Bug: none
Change-Id: I8c92dfaca95619fe6661af10c018a75dae7e25ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537787
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827526}
This is implemented as OnceCallbackList vs. RepeatingCallbackList. It
might in theory be nice to simply have a single CallbackList that
supports simultaneously containing both Once and Repeating callbacks.
However, I don't personally need it, and while I suspect it's possible,
I didn't want to try and figure it out.
Bug: none
Change-Id: Ib04d39adedca5b15e002b1b3d5df8957b40f2254
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2174162
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766187}
Remove some usage of deprecated callback types in base/*. Where possible
convert to the corresponding once type, otherwise replace with the
repeating type.
Also remove the PRESUBMIT rule exception that allows the deprecated
callback types in base/*. Note the PRESUBMIT rule uses a regex that
includes base:: so it doesn't catch usage inside namespace base that
isn't fully qualified.
Bug: 714018
Change-Id: I52acb7f46a7f447d189f2ae066fa89f593fb682d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795573
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695798}
Remove some usage of deprecated callback types in base/*. Where possible
convert to the corresponding once type, otherwise replace with the
repeating type.
Bug: 714018
Change-Id: I769373b6bb9c4ae3331faf71e8a666bff6f0611f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1690929
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678111}
This change introduces the SFINAE friendly EnableIfIsBaseCallback type
helper, allowing code to restrict templates to classes that are
base::Callbacks (either OnceCallback or RepeatingCallback). Furthermore,
this change cleans up some code duplication.
TBR=reillyg@chromium.org
Bug: 714018
Change-Id: I0a49da990aca03e5cf2b7c71c74e7c8c53245008
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1583812
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654390}
After this CL, ScopedClosureRunner uses base::OnceClosure as its internal
callback object. That implies it gets able to take base::OnceClosure in
addition to base::Closure, and ScopedClosureRunner::Release returns
base::OnceClosure instead of base::Closure.
Bug: 714018
Change-Id: I031ef7b70bc9673ea7781e292719e26ddc74b1a7
Reviewed-on: https://chromium-review.googlesource.com/597090
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Zijie He <zijiehe@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#492538}
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}
ResetAndReturn's OnceCallback was broken, since it tried to copy the
move only OnceCallback. This CL fixes that and adds test for it.
Review-Url: https://codereview.chromium.org/2709913002
Cr-Commit-Position: refs/heads/master@{#451949}
ScopedCallbackRunner.Reset() was used in two places with
assumption it doesn't call current callback. Replaced Reset()
with ReplaceClosure() and RunAndReset() to make behavior clearer.
Review-Url: https://codereview.chromium.org/2094803005
Cr-Commit-Position: refs/heads/master@{#404277}
With this change ScopedClosureRunner will be movable. This will
allow to store instances of that class in STL containers, e.g. to store
list of callbacks to be called when certain event happens.
Review-Url: https://codereview.chromium.org/2091503004
Cr-Commit-Position: refs/heads/master@{#402031}