0
Commit Graph

18 Commits

Author SHA1 Message Date
Joshua Bell
06e5791cb0 Remove base::AdaptCallbackForRepeating
All usages have been removed from the codebase. \o/

* Remove implementation/tests from base/
* Remove clang rewriter from tools/

Bug: 730593
Change-Id: I101e65ffc0c626aa101e4e51396558fbdf16c372
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2941842
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#890311}
2021-06-08 17:24:15 +00:00
danakj
6989c6c05e Replace AdaptCallbackForRepeating with SplitOnceCallback in content/browser/tracing
SplitOnceCallback keeps the types correct, with 2 OnceCallbacks, and
ensures only one of the two is called at runtime.

Bug: 730593
Change-Id: I0ec819954bf7feda821c95839b6c19ab295d5807
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2893604
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#882720}
2021-05-13 22:20:31 +00:00
Colin Blundell
ea615d420d [base::{Bind, Callback conversion] Update refs in docs/comments/misc
After the removal of the deprecated base::Bind and base::Callback APIs,
this CL sweeps through the codebase removing references that are outside
of code compiled as part of Chromium CI. This is almost entirely docs
and comments, with some other miscellaneous files as well (e.g., checks
of various kinds).

Bug: 714018
Change-Id: Ide8845d92527031821aaa9fd3a00f75f9ba76545
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2874622
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Reviewed-by: Peter Collingbourne <pcc@chromium.org>
Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#881967}
2021-05-12 09:35:41 +00:00
danakj
a95d28c43f Add tests for splitting a split OnceCallback.
You can generate as many OnceCallbacks as you need, and they all will
allow you to call the underlying functor once, and crash if you call
it again.

R=jdoerrie@chromium.org

Change-Id: Ib2d722409073546400004fe34d0e5fe2a07f3b1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2783263
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#866100}
2021-03-24 13:59:32 +00:00
Thomas Guilbert
5db523811a Add SplitOnceCallback
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}
2020-12-17 22:33:14 +00:00
Peter Kasting
323ccc86ad Fix a variety of small issues with ScopedClosureRunner.
* 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}
2020-11-14 01:41:24 +00:00
Peter Kasting
56bc40c08d Use CRTP to avoid |null_callbacks_| for RepeatingCallbackList.
Bug: none
Change-Id: I5ea12772f8dddca924fb55d702129e901e236983
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2191247
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768168}
2020-05-13 06:41:57 +00:00
Peter Kasting
670a86bd54 CallbackList improvements, part 4: OnceCallback support
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}
2020-05-06 22:50:02 +00:00
kylechar
2255ccc731 base: Cleanup callback types (part 7).
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}
2019-09-11 21:47:23 +00:00
kylechar
650caf0ede base: Cleanup callback types (part 6).
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}
2019-07-17 03:25:41 +00:00
Daniel Cheng
6bfb082b16 [🧹] Remove base::ResetAndReturn.
Bug: 841899
Tbr: thestig@chromium.org
Change-Id: I972785b8f6c189039c56049a8c132b7bf4c69876
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1584531
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656276}
2019-05-03 01:53:00 +00:00
jdoerrie
19cf521b39 [base] Introduce EnableIfIsBaseCallback Type Helper
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}
2019-04-26 09:50:47 +00:00
tzik
398065c8f7 Convert base::ScopedClosureRunner to use OnceCallback
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}
2017-08-08 05:19:40 +00:00
tzik
faa3495a7a 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}
2017-04-20 12:19:50 +00:00
tzik
6eb028403e Fix OnceCallback support of base::ResetAndReturn
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}
2017-02-22 09:13:19 +00:00
sergeyu
668613aa8e Fix incorrect usage of ScopedCallbackRunner.Reset().
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}
2016-07-08 00:36:39 +00:00
sergeyu
e4be191768 Add move constructor in ScopedClosureRunner.
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}
2016-06-25 00:53:35 +00:00
avi@chromium.org
1c232c2bbc Move ScopedClosureRunner to callback_helpers, add Reset.
BUG=none
TEST=none
TBR=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/23514018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220473 0039d316-1c4b-4281-b951-d872f2087c98
2013-08-30 02:04:04 +00:00