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

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

Issue 1179733005: Update mojo sdk to rev bdbb0c7e396fc4044a8b194058d7a7e529715286 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update CommandBufferImpl (Binding::OnConnectionError is no more) Created 5 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: third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h b/third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h
index c891a21f3ee3d46a0160ba54e99442c31ece28c6..48c74c6eb67b1807b2279100589ac5528ad2a3b5 100644
--- a/third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h
@@ -9,6 +9,7 @@
#include "mojo/public/c/environment/async_waiter.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/public/cpp/bindings/error_handler.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
@@ -44,12 +45,12 @@ namespace mojo {
// }
// };
template <typename Interface>
-class StrongBinding : public ErrorHandler {
+class StrongBinding {
MOJO_MOVE_ONLY_TYPE(StrongBinding)
public:
explicit StrongBinding(Interface* impl) : binding_(impl) {
- binding_.set_error_handler(this);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
StrongBinding(
@@ -76,7 +77,7 @@ class StrongBinding : public ErrorHandler {
binding_.Bind(request.Pass(), waiter);
}
- ~StrongBinding() override {}
+ ~StrongBinding() {}
void Bind(
ScopedMessagePipeHandle handle,
@@ -103,23 +104,32 @@ class StrongBinding : public ErrorHandler {
return binding_.WaitForIncomingMethodCall();
}
+ void set_connection_error_handler(const Closure& error_handler) {
+ connection_error_handler_ = error_handler;
+ }
+
+ // NOTE: Deprecated. Please use the method above.
+ // TODO(yzshen): Remove this method once all callsites are converted.
void set_error_handler(ErrorHandler* error_handler) {
- error_handler_ = error_handler;
+ if (error_handler) {
+ set_connection_error_handler(
+ [error_handler]() { error_handler->OnConnectionError(); });
+ } else {
+ set_connection_error_handler(Closure());
+ }
}
Interface* impl() { return binding_.impl(); }
// Exposed for testing, should not generally be used.
internal::Router* internal_router() { return binding_.internal_router(); }
- // ErrorHandler implementation
- void OnConnectionError() override {
- if (error_handler_)
- error_handler_->OnConnectionError();
+ void OnConnectionError() {
+ connection_error_handler_.Run();
delete binding_.impl();
}
private:
- ErrorHandler* error_handler_ = nullptr;
+ Closure connection_error_handler_;
Binding<Interface> binding_;
};

Powered by Google App Engine
This is Rietveld 408576698