0

Clarify documentation for self-destructing callbacks.

It's also okay to copy a RepeatingCallback onto the stack before running
it if running it may cause it to be deleted.

Bug: 1161804
Change-Id: I4ee5d81b5ab82505c4c3b02f872d3400d3d93ceb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2607886
Auto-Submit: Greg Thompson <grt@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840012}
This commit is contained in:
Greg Thompson
2021-01-04 10:10:02 +00:00
committed by Chromium LUCI CQ
parent 875f6b08b3
commit ddc84d470a

@ -372,9 +372,9 @@ void DoSomething(const base::RepeatingCallback<double(double)>& callback) {
If running a callback could result in its own destruction (e.g., if the callback
recipient deletes the object the callback is a member of), the callback should
be moved before it can be safely invoked. (Note that this is only an issue for
RepeatingCallbacks, because a OnceCallback always has to be moved for
execution.)
be moved or copied onto the stack before it can be safely invoked. (Note that
this is only an issue for RepeatingCallbacks, because a OnceCallback always has
to be moved for execution.)
```cpp
void Foo::RunCallback() {