Index: mojo/public/cpp/bindings/lib/interface_impl_internal.h |
diff --git a/mojo/public/cpp/bindings/lib/interface_impl_internal.h b/mojo/public/cpp/bindings/lib/interface_impl_internal.h |
index 26f2443515c31f775c3cb270b3b1aafc2076d976..e661290fece266cc2ae6bdcab5b10e50c61a3e56 100644 |
--- a/mojo/public/cpp/bindings/lib/interface_impl_internal.h |
+++ b/mojo/public/cpp/bindings/lib/interface_impl_internal.h |
@@ -15,11 +15,19 @@ namespace mojo { |
namespace internal { |
template <typename Interface> |
+class InterfaceImplBase : public Interface { |
+ public: |
+ virtual ~InterfaceImplBase() {} |
+ virtual void OnConnectionEstablished() = 0; |
+ virtual void OnConnectionError() = 0; |
+}; |
+ |
+template <typename Interface> |
class InterfaceImplState : public ErrorHandler { |
public: |
typedef typename Interface::Client Client; |
- explicit InterfaceImplState(WithErrorHandler<Interface>* instance) |
+ explicit InterfaceImplState(InterfaceImplBase<Interface>* instance) |
: router_(NULL), |
client_(NULL), |
proxy_(NULL) { |
@@ -58,7 +66,8 @@ class InterfaceImplState : public ErrorHandler { |
proxy_ = new typename Client::Proxy_(router_); |
- stub_.sink()->SetClient(proxy_); |
+ instance()->SetClient(proxy_); |
+ instance()->OnConnectionEstablished(); |
} |
Router* router() { return router_; } |
@@ -67,9 +76,12 @@ class InterfaceImplState : public ErrorHandler { |
Client* client() { return client_; } |
private: |
+ InterfaceImplBase<Interface>* instance() { |
+ return static_cast<InterfaceImplBase<Interface>*>(stub_.sink()); |
+ } |
+ |
virtual void OnConnectionError() MOJO_OVERRIDE { |
- static_cast<WithErrorHandler<Interface>*>(stub_.sink())-> |
- OnConnectionError(); |
+ instance()->OnConnectionError(); |
} |
Router* router_; |