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

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

Issue 1531543003: Modify bindings to enforce that an error handler callback is only set after binding to a msg pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-error-handler
Patch Set: Add error handler comment. Created 5 years 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/lib/binding_state.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 860260ed7d7bea6763318a787d069ba54dc212da..863bca1ab62a06cf087974d5f9374a60cc50b475 100644
--- a/mojo/public/cpp/bindings/strong_binding.h
+++ b/mojo/public/cpp/bindings/strong_binding.h
@@ -48,16 +48,14 @@ class StrongBinding {
MOJO_MOVE_ONLY_TYPE(StrongBinding)
public:
- explicit StrongBinding(Interface* impl) : binding_(impl) {
- binding_.set_connection_error_handler([this]() { OnConnectionError(); });
- }
+ explicit StrongBinding(Interface* impl) : binding_(impl) {}
StrongBinding(
Interface* impl,
ScopedMessagePipeHandle handle,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter())
: StrongBinding(impl) {
- binding_.Bind(handle.Pass(), waiter);
+ Bind(handle.Pass(), waiter);
}
StrongBinding(
@@ -65,7 +63,7 @@ class StrongBinding {
InterfacePtr<Interface>* ptr,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter())
: StrongBinding(impl) {
- binding_.Bind(ptr, waiter);
+ Bind(ptr, waiter);
}
StrongBinding(
@@ -73,7 +71,7 @@ class StrongBinding {
InterfaceRequest<Interface> request,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter())
: StrongBinding(impl) {
- binding_.Bind(request.Pass(), waiter);
+ Bind(request.Pass(), waiter);
}
~StrongBinding() {}
@@ -83,6 +81,7 @@ class StrongBinding {
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
assert(!binding_.is_bound());
binding_.Bind(handle.Pass(), waiter);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
void Bind(
@@ -90,6 +89,7 @@ class StrongBinding {
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
assert(!binding_.is_bound());
binding_.Bind(ptr, waiter);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
void Bind(
@@ -97,6 +97,7 @@ class StrongBinding {
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
assert(!binding_.is_bound());
binding_.Bind(request.Pass(), waiter);
+ binding_.set_connection_error_handler([this]() { OnConnectionError(); });
}
bool WaitForIncomingMethodCall() {
@@ -104,7 +105,11 @@ class StrongBinding {
}
// Note: The error handler must not delete the interface implementation.
+ //
+ // This method may only be called after this StrongBinding has been bound to a
+ // message pipe.
void set_connection_error_handler(const Closure& error_handler) {
+ assert(binding_.is_bound());
connection_error_handler_ = error_handler;
}
« no previous file with comments | « mojo/public/cpp/bindings/lib/binding_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698