Chromium Code Reviews| Index: mojo/public/cpp/bindings/interface_impl.h |
| diff --git a/mojo/public/cpp/bindings/interface_impl.h b/mojo/public/cpp/bindings/interface_impl.h |
| index 4a78cb4b05a1f11b4380a001aab45fa76e91a8e2..387c62d0a41ec522c895738db2fbfd00325d3c40 100644 |
| --- a/mojo/public/cpp/bindings/interface_impl.h |
| +++ b/mojo/public/cpp/bindings/interface_impl.h |
| @@ -55,6 +55,15 @@ class InterfaceImpl : public internal::InterfaceImplBase<Interface> { |
| MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceImpl); |
| }; |
| +// Use InterfaceImplDeleteOnError if your interface implementation should delete |
| +// itself when detecting a connection error. |
| +template <typename Interface> |
| +class InterfaceImplDeleteOnError : public InterfaceImpl<Interface> { |
| + public: |
| + virtual ~InterfaceImplDeleteOnError() {} |
| + virtual void OnConnectionError() { delete this; } |
|
tim (not reviewing)
2014/07/11 01:33:41
I might be missing something, but I think one thin
darin (slow to review)
2014/07/11 03:52:35
A template arg to InterfaceImpl<> would help solve
|
| +}; |
| + |
| // Takes an instance of an InterfaceImpl<..> subclass and binds it to the given |
| // MessagePipe. The instance is returned for convenience in member initializer |
| // lists, etc. If the pipe is closed, the instance's OnConnectionError method |