| 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 12 matching lines...) Expand all Loading... |
| 23 virtual void OnConnectionEstablished() = 0; | 23 virtual void OnConnectionEstablished() = 0; |
| 24 virtual void OnConnectionError() = 0; | 24 virtual void OnConnectionError() = 0; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 template <typename Interface> | 27 template <typename Interface> |
| 28 class InterfaceImplState : public ErrorHandler { | 28 class InterfaceImplState : public ErrorHandler { |
| 29 public: | 29 public: |
| 30 typedef typename Interface::Client Client; | 30 typedef typename Interface::Client Client; |
| 31 | 31 |
| 32 explicit InterfaceImplState(InterfaceImplBase<Interface>* instance) | 32 explicit InterfaceImplState(InterfaceImplBase<Interface>* instance) |
| 33 : router_(NULL), | 33 : router_(nullptr), |
| 34 proxy_(NULL), | 34 proxy_(nullptr), |
| 35 instance_bound_to_pipe_(false) | 35 instance_bound_to_pipe_(false) |
| 36 #ifndef NDEBUG | 36 #ifndef NDEBUG |
| 37 , | 37 , |
| 38 deleting_instance_due_to_error_(false) | 38 deleting_instance_due_to_error_(false) |
| 39 #endif | 39 #endif |
| 40 { | 40 { |
| 41 MOJO_DCHECK(instance); | 41 MOJO_DCHECK(instance); |
| 42 stub_.set_sink(instance); | 42 stub_.set_sink(instance); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~InterfaceImplState() { | 45 virtual ~InterfaceImplState() { |
| 46 #ifndef NDEBUG | 46 #ifndef NDEBUG |
| 47 MOJO_DCHECK(!instance_bound_to_pipe_ || deleting_instance_due_to_error_); | 47 MOJO_DCHECK(!instance_bound_to_pipe_ || deleting_instance_due_to_error_); |
| 48 #endif | 48 #endif |
| 49 delete proxy_; | 49 delete proxy_; |
| 50 if (router_) { | 50 if (router_) { |
| 51 router_->set_error_handler(NULL); | 51 router_->set_error_handler(nullptr); |
| 52 delete router_; | 52 delete router_; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 void BindProxy( | 56 void BindProxy( |
| 57 InterfacePtr<Interface>* ptr, | 57 InterfacePtr<Interface>* ptr, |
| 58 bool instance_bound_to_pipe, | 58 bool instance_bound_to_pipe, |
| 59 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { | 59 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) { |
| 60 MessagePipe pipe; | 60 MessagePipe pipe; |
| 61 ptr->Bind(pipe.handle0.Pass(), waiter); | 61 ptr->Bind(pipe.handle0.Pass(), waiter); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |