OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_IMPL_INTERNAL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_IMPL_INTERNAL_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_IMPL_INTERNAL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_IMPL_INTERNAL_H_ |
7 | 7 |
8 #include "mojo/public/cpp/bindings/error_handler.h" | 8 #include "mojo/public/cpp/bindings/error_handler.h" |
9 #include "mojo/public/cpp/bindings/interface_ptr.h" | 9 #include "mojo/public/cpp/bindings/interface_ptr.h" |
10 #include "mojo/public/cpp/bindings/lib/filter_chain.h" | 10 #include "mojo/public/cpp/bindings/lib/filter_chain.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 Router* router() { return router_; } | 91 Router* router() { return router_; } |
92 Client* client() { return proxy_; } | 92 Client* client() { return proxy_; } |
93 | 93 |
94 private: | 94 private: |
95 InterfaceImplBase<Interface>* instance() { | 95 InterfaceImplBase<Interface>* instance() { |
96 return static_cast<InterfaceImplBase<Interface>*>(stub_.sink()); | 96 return static_cast<InterfaceImplBase<Interface>*>(stub_.sink()); |
97 } | 97 } |
98 | 98 |
99 virtual void OnConnectionError() MOJO_OVERRIDE { | 99 virtual void OnConnectionError() override { |
100 // If the the instance is not bound to the pipe, the instance might choose | 100 // If the the instance is not bound to the pipe, the instance might choose |
101 // to delete itself in the OnConnectionError handler, which would in turn | 101 // to delete itself in the OnConnectionError handler, which would in turn |
102 // delete this. Save the error behavior before invoking the error handler | 102 // delete this. Save the error behavior before invoking the error handler |
103 // so we can correctly decide what to do. | 103 // so we can correctly decide what to do. |
104 bool bound = instance_bound_to_pipe_; | 104 bool bound = instance_bound_to_pipe_; |
105 instance()->OnConnectionError(); | 105 instance()->OnConnectionError(); |
106 if (!bound) | 106 if (!bound) |
107 return; | 107 return; |
108 #ifndef NDEBUG | 108 #ifndef NDEBUG |
109 deleting_instance_due_to_error_ = true; | 109 deleting_instance_due_to_error_ = true; |
110 #endif | 110 #endif |
111 delete instance(); | 111 delete instance(); |
112 } | 112 } |
113 | 113 |
114 Router* router_; | 114 Router* router_; |
115 typename Client::Proxy_* proxy_; | 115 typename Client::Proxy_* proxy_; |
116 typename Interface::Stub_ stub_; | 116 typename Interface::Stub_ stub_; |
117 bool instance_bound_to_pipe_; | 117 bool instance_bound_to_pipe_; |
118 #ifndef NDEBUG | 118 #ifndef NDEBUG |
119 bool deleting_instance_due_to_error_; | 119 bool deleting_instance_due_to_error_; |
120 #endif | 120 #endif |
121 | 121 |
122 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceImplState); | 122 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceImplState); |
123 }; | 123 }; |
124 | 124 |
125 } // namespace internal | 125 } // namespace internal |
126 } // namespace mojo | 126 } // namespace mojo |
127 | 127 |
128 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_IMPL_INTERNAL_H_ | 128 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_IMPL_INTERNAL_H_ |
OLD | NEW |