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

Unified Diff: mojo/public/cpp/bindings/strong_binding.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
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 5c48eae08b195d28a7e171585f1e4ea04e74841f..adc96fa30b049ec81e07f551ff0317a2d26f8c6b 100644
--- a/mojo/public/cpp/bindings/strong_binding.h
+++ b/mojo/public/cpp/bindings/strong_binding.h
@@ -7,6 +7,7 @@
#include <utility>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -72,19 +73,22 @@ class StrongBinding {
void Bind(ScopedMessagePipeHandle handle) {
DCHECK(!binding_.is_bound());
binding_.Bind(std::move(handle));
- binding_.set_connection_error_handler([this]() { OnConnectionError(); });
+ binding_.set_connection_error_handler(
+ base::Bind(&StrongBinding::OnConnectionError, base::Unretained(this)));
}
void Bind(InterfacePtr<Interface>* ptr) {
DCHECK(!binding_.is_bound());
binding_.Bind(ptr);
- binding_.set_connection_error_handler([this]() { OnConnectionError(); });
+ binding_.set_connection_error_handler(
+ base::Bind(&StrongBinding::OnConnectionError, base::Unretained(this)));
}
void Bind(InterfaceRequest<Interface> request) {
DCHECK(!binding_.is_bound());
binding_.Bind(std::move(request));
- binding_.set_connection_error_handler([this]() { OnConnectionError(); });
+ binding_.set_connection_error_handler(
+ base::Bind(&StrongBinding::OnConnectionError, base::Unretained(this)));
}
bool WaitForIncomingMethodCall() {
@@ -105,11 +109,16 @@ class StrongBinding {
internal::Router* internal_router() { return binding_.internal_router(); }
void OnConnectionError() {
- connection_error_handler_.Run();
+ RunConnectionErrorHandler();
yzshen1 2016/06/18 00:01:18 nit: maybe no need to have such a helper because t
Ken Rockot(use gerrit already) 2016/06/18 03:24:26 Oops, done.
delete binding_.impl();
}
private:
+ void RunConnectionErrorHandler() {
+ if (!connection_error_handler_.is_null())
+ connection_error_handler_.Run();
+ }
+
Closure connection_error_handler_;
Binding<Interface> binding_;

Powered by Google App Engine
This is Rietveld 408576698