| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BINDING_STATE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 explicit BindingState(Interface* impl) : impl_(impl) { | 43 explicit BindingState(Interface* impl) : impl_(impl) { |
| 44 stub_.set_sink(impl_); | 44 stub_.set_sink(impl_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 ~BindingState() { Close(); } | 47 ~BindingState() { Close(); } |
| 48 | 48 |
| 49 void Bind(ScopedMessagePipeHandle handle, | 49 void Bind(ScopedMessagePipeHandle handle, |
| 50 scoped_refptr<base::SingleThreadTaskRunner> runner) { | 50 scoped_refptr<base::SingleThreadTaskRunner> runner) { |
| 51 DCHECK(!router_); | 51 DCHECK(!router_); |
| 52 internal::FilterChain filters; | 52 internal::FilterChain filters; |
| 53 filters.Append<internal::MessageHeaderValidator>(); | 53 filters.Append<internal::MessageHeaderValidator>(Interface::Name_); |
| 54 filters.Append<typename Interface::RequestValidator_>(); | 54 filters.Append<typename Interface::RequestValidator_>(); |
| 55 | 55 |
| 56 router_ = | 56 router_ = |
| 57 new internal::Router(std::move(handle), std::move(filters), | 57 new internal::Router(std::move(handle), std::move(filters), |
| 58 Interface::HasSyncMethods_, std::move(runner)); | 58 Interface::HasSyncMethods_, std::move(runner)); |
| 59 router_->set_incoming_receiver(&stub_); | 59 router_->set_incoming_receiver(&stub_); |
| 60 router_->set_connection_error_handler( | 60 router_->set_connection_error_handler( |
| 61 [this]() { connection_error_handler_.Run(); }); | 61 [this]() { connection_error_handler_.Run(); }); |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 stub_.set_sink(impl_); | 139 stub_.set_sink(impl_); |
| 140 } | 140 } |
| 141 | 141 |
| 142 ~BindingState() { Close(); } | 142 ~BindingState() { Close(); } |
| 143 | 143 |
| 144 void Bind(ScopedMessagePipeHandle handle, | 144 void Bind(ScopedMessagePipeHandle handle, |
| 145 scoped_refptr<base::SingleThreadTaskRunner> runner) { | 145 scoped_refptr<base::SingleThreadTaskRunner> runner) { |
| 146 DCHECK(!router_); | 146 DCHECK(!router_); |
| 147 | 147 |
| 148 router_ = new internal::MultiplexRouter(false, std::move(handle), runner); | 148 router_ = new internal::MultiplexRouter(false, std::move(handle), runner); |
| 149 router_->SetMasterInterfaceName(Interface::Name_); |
| 149 stub_.serialization_context()->router = router_; | 150 stub_.serialization_context()->router = router_; |
| 150 | 151 |
| 151 endpoint_client_.reset(new internal::InterfaceEndpointClient( | 152 endpoint_client_.reset(new internal::InterfaceEndpointClient( |
| 152 router_->CreateLocalEndpointHandle(internal::kMasterInterfaceId), | 153 router_->CreateLocalEndpointHandle(internal::kMasterInterfaceId), |
| 153 &stub_, base::WrapUnique(new typename Interface::RequestValidator_()), | 154 &stub_, base::WrapUnique(new typename Interface::RequestValidator_()), |
| 154 Interface::HasSyncMethods_, std::move(runner))); | 155 Interface::HasSyncMethods_, std::move(runner))); |
| 155 | 156 |
| 156 endpoint_client_->set_connection_error_handler( | 157 endpoint_client_->set_connection_error_handler( |
| 157 [this]() { connection_error_handler_.Run(); }); | 158 [this]() { connection_error_handler_.Run(); }); |
| 158 } | 159 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 Interface* impl_; | 227 Interface* impl_; |
| 227 Closure connection_error_handler_; | 228 Closure connection_error_handler_; |
| 228 | 229 |
| 229 DISALLOW_COPY_AND_ASSIGN(BindingState); | 230 DISALLOW_COPY_AND_ASSIGN(BindingState); |
| 230 }; | 231 }; |
| 231 | 232 |
| 232 } // namesapce internal | 233 } // namesapce internal |
| 233 } // namespace mojo | 234 } // namespace mojo |
| 234 | 235 |
| 235 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ | 236 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ |
| OLD | NEW |