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

Unified Diff: mojo/public/cpp/bindings/strong_binding.h

Issue 2932193002: Use OnceCallback for Mojo binding connection error handlers. (Closed)
Patch Set: Call Run() on rvalue. Created 3 years, 6 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 | « mojo/public/cpp/bindings/strong_associated_binding.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/strong_binding.h
diff --git a/mojo/public/cpp/bindings/strong_binding.h b/mojo/public/cpp/bindings/strong_binding.h
index f4b4a061cd9290955fa94a48f21771bde22267ab..29ba273db5f8aa15a1172ddf5aa6990e27da1b4e 100644
--- a/mojo/public/cpp/bindings/strong_binding.h
+++ b/mojo/public/cpp/bindings/strong_binding.h
@@ -59,16 +59,16 @@ class StrongBinding {
//
// This method may only be called after this StrongBinding has been bound to a
// message pipe.
- void set_connection_error_handler(const base::Closure& error_handler) {
+ void set_connection_error_handler(base::OnceClosure error_handler) {
DCHECK(binding_.is_bound());
- connection_error_handler_ = error_handler;
+ connection_error_handler_ = std::move(error_handler);
connection_error_with_reason_handler_.Reset();
}
void set_connection_error_with_reason_handler(
- const ConnectionErrorWithReasonCallback& error_handler) {
+ ConnectionErrorWithReasonCallback error_handler) {
DCHECK(binding_.is_bound());
- connection_error_with_reason_handler_ = error_handler;
+ connection_error_with_reason_handler_ = std::move(error_handler);
connection_error_handler_.Reset();
}
@@ -97,15 +97,17 @@ class StrongBinding {
void OnConnectionError(uint32_t custom_reason,
const std::string& description) {
- if (!connection_error_handler_.is_null())
- connection_error_handler_.Run();
- else if (!connection_error_with_reason_handler_.is_null())
- connection_error_with_reason_handler_.Run(custom_reason, description);
+ if (connection_error_handler_) {
+ std::move(connection_error_handler_).Run();
+ } else if (connection_error_with_reason_handler_) {
+ std::move(connection_error_with_reason_handler_)
+ .Run(custom_reason, description);
+ }
Close();
}
std::unique_ptr<Interface> impl_;
- base::Closure connection_error_handler_;
+ base::OnceClosure connection_error_handler_;
ConnectionErrorWithReasonCallback connection_error_with_reason_handler_;
Binding<Interface> binding_;
base::WeakPtrFactory<StrongBinding> weak_factory_;
« no previous file with comments | « mojo/public/cpp/bindings/strong_associated_binding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698