Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: docs/callback.md

Issue 2755073002: Update documentation for base::ResetAndReturn(Callback*) (Closed)
Patch Set: return type Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/callback_helpers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: docs/callback.md
diff --git a/docs/callback.md b/docs/callback.md
index 6b7dd6931f5009a402696c7753c619a48ff98b62..4194d5107995219c4dc65919040635eddd42cc0c 100644
--- a/docs/callback.md
+++ b/docs/callback.md
@@ -152,6 +152,17 @@ void DoSomething(const 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. The `base::ResetAndReturn` method
+provides this functionality.
+
+```cpp
+void Foo::RunCallback() {
+ base::ResetAndReturn(&foo_deleter_callback_).Run();
+}
+```
+
### Passing Unbound Input Parameters
Unbound parameters are specified at the time a callback is `Run()`. They are
« no previous file with comments | « base/callback_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698