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

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

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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/associated_binding.h ('k') | mojo/public/cpp/bindings/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 f2c948029a5bd3510f2a1d105f91ef179f019720..a22df5e05146bdef8af40551ee5c9556ac48d603 100644
--- a/mojo/public/cpp/bindings/binding_set.h
+++ b/mojo/public/cpp/bindings/binding_set.h
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -29,7 +30,8 @@ class BindingSet {
void AddBinding(Interface* impl, InterfaceRequest<Interface> request) {
auto binding = new Element(impl, std::move(request));
- binding->set_connection_error_handler([this]() { OnConnectionError(); });
+ binding->set_connection_error_handler(
+ base::Bind(&BindingSet::OnConnectionError, base::Unretained(this)));
bindings_.push_back(binding->GetWeakPtr());
}
@@ -58,7 +60,8 @@ class BindingSet {
public:
Element(Interface* impl, InterfaceRequest<Interface> request)
: binding_(impl, std::move(request)), weak_ptr_factory_(this) {
- binding_.set_connection_error_handler([this]() { OnConnectionError(); });
+ binding_.set_connection_error_handler(
+ base::Bind(&Element::OnConnectionError, base::Unretained(this)));
}
~Element() {}
@@ -76,7 +79,8 @@ class BindingSet {
void OnConnectionError() {
Closure error_handler = error_handler_;
delete this;
- error_handler.Run();
+ if (!error_handler.is_null())
+ error_handler.Run();
}
private:
@@ -95,7 +99,8 @@ class BindingSet {
}),
bindings_.end());
- error_handler_.Run();
+ if (!error_handler_.is_null())
+ error_handler_.Run();
}
Closure error_handler_;
« no previous file with comments | « mojo/public/cpp/bindings/associated_binding.h ('k') | mojo/public/cpp/bindings/callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698