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

Unified Diff: mojo/public/cpp/bindings/binding_set.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/binding.h ('k') | mojo/public/cpp/bindings/connection_error_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/binding_set.h
diff --git a/mojo/public/cpp/bindings/binding_set.h b/mojo/public/cpp/bindings/binding_set.h
index 84b6c64cb67435659d40a467440f451cc65cec4a..c66183923aabc667aed90e4ea14bc3ff64322f4c 100644
--- a/mojo/public/cpp/bindings/binding_set.h
+++ b/mojo/public/cpp/bindings/binding_set.h
@@ -73,14 +73,14 @@ class BindingSetBase {
BindingSetBase() {}
- void set_connection_error_handler(const base::Closure& error_handler) {
- error_handler_ = error_handler;
+ void set_connection_error_handler(base::RepeatingClosure error_handler) {
+ error_handler_ = std::move(error_handler);
error_with_reason_handler_.Reset();
}
void set_connection_error_with_reason_handler(
- const ConnectionErrorWithReasonCallback& error_handler) {
- error_with_reason_handler_ = error_handler;
+ RepeatingConnectionErrorWithReasonCallback error_handler) {
+ error_with_reason_handler_ = std::move(error_handler);
error_handler_.Reset();
}
@@ -182,7 +182,7 @@ class BindingSetBase {
if (ContextTraits::SupportsContext())
binding_.AddFilter(base::MakeUnique<DispatchFilter>(this));
binding_.set_connection_error_with_reason_handler(
- base::Bind(&Entry::OnConnectionError, base::Unretained(this)));
+ base::BindOnce(&Entry::OnConnectionError, base::Unretained(this)));
}
void FlushForTesting() { binding_.FlushForTesting(); }
@@ -254,14 +254,15 @@ class BindingSetBase {
if (!is_flushing_)
bindings_.erase(it);
- if (!error_handler_.is_null())
+ if (error_handler_) {
error_handler_.Run();
- else if (!error_with_reason_handler_.is_null())
+ } else if (error_with_reason_handler_) {
error_with_reason_handler_.Run(custom_reason, description);
+ }
}
- base::Closure error_handler_;
- ConnectionErrorWithReasonCallback error_with_reason_handler_;
+ base::RepeatingClosure error_handler_;
+ RepeatingConnectionErrorWithReasonCallback error_with_reason_handler_;
PreDispatchCallback pre_dispatch_handler_;
BindingId next_binding_id_ = 0;
std::map<BindingId, std::unique_ptr<Entry>> bindings_;
« no previous file with comments | « mojo/public/cpp/bindings/binding.h ('k') | mojo/public/cpp/bindings/connection_error_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698