| 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_PTR_STATE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> // For |std::swap()|. | 10 #include <algorithm> // For |std::swap()|. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // The proxy has been configured. | 157 // The proxy has been configured. |
| 158 if (proxy_) { | 158 if (proxy_) { |
| 159 DCHECK(router_); | 159 DCHECK(router_); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 // The object hasn't been bound. | 162 // The object hasn't been bound. |
| 163 if (!handle_.is_valid()) | 163 if (!handle_.is_valid()) |
| 164 return; | 164 return; |
| 165 | 165 |
| 166 FilterChain filters; | 166 FilterChain filters; |
| 167 filters.Append<MessageHeaderValidator>(); | 167 filters.Append<MessageHeaderValidator>(Interface::Name_); |
| 168 filters.Append<typename Interface::ResponseValidator_>(); | 168 filters.Append<typename Interface::ResponseValidator_>(); |
| 169 | 169 |
| 170 router_ = new Router(std::move(handle_), std::move(filters), false, | 170 router_ = new Router(std::move(handle_), std::move(filters), false, |
| 171 std::move(runner_)); | 171 std::move(runner_)); |
| 172 router_->set_interface_name(Interface::Name_); |
| 172 | 173 |
| 173 proxy_ = new Proxy(router_); | 174 proxy_ = new Proxy(router_); |
| 174 } | 175 } |
| 175 | 176 |
| 176 Proxy* proxy_; | 177 Proxy* proxy_; |
| 177 Router* router_; | 178 Router* router_; |
| 178 | 179 |
| 179 // |proxy_| and |router_| are not initialized until read/write with the | 180 // |proxy_| and |router_| are not initialized until read/write with the |
| 180 // message pipe handle is needed. |handle_| is valid between the Bind() call | 181 // message pipe handle is needed. |handle_| is valid between the Bind() call |
| 181 // and the initialization of |proxy_| and |router_|. | 182 // and the initialization of |proxy_| and |router_|. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (proxy_) { | 319 if (proxy_) { |
| 319 DCHECK(router_); | 320 DCHECK(router_); |
| 320 DCHECK(endpoint_client_); | 321 DCHECK(endpoint_client_); |
| 321 return; | 322 return; |
| 322 } | 323 } |
| 323 // The object hasn't been bound. | 324 // The object hasn't been bound. |
| 324 if (!handle_.is_valid()) | 325 if (!handle_.is_valid()) |
| 325 return; | 326 return; |
| 326 | 327 |
| 327 router_ = new MultiplexRouter(true, std::move(handle_), runner_); | 328 router_ = new MultiplexRouter(true, std::move(handle_), runner_); |
| 329 router_->SetMasterInterfaceName(Interface::Name_); |
| 328 endpoint_client_.reset(new InterfaceEndpointClient( | 330 endpoint_client_.reset(new InterfaceEndpointClient( |
| 329 router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr, | 331 router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr, |
| 330 base::WrapUnique(new typename Interface::ResponseValidator_()), false, | 332 base::WrapUnique(new typename Interface::ResponseValidator_()), false, |
| 331 std::move(runner_))); | 333 std::move(runner_))); |
| 334 endpoint_client_->set_interface_name(Interface::Name_); |
| 332 proxy_.reset(new Proxy(endpoint_client_.get())); | 335 proxy_.reset(new Proxy(endpoint_client_.get())); |
| 333 proxy_->serialization_context()->router = endpoint_client_->router(); | 336 proxy_->serialization_context()->router = endpoint_client_->router(); |
| 334 } | 337 } |
| 335 | 338 |
| 336 scoped_refptr<MultiplexRouter> router_; | 339 scoped_refptr<MultiplexRouter> router_; |
| 337 | 340 |
| 338 std::unique_ptr<InterfaceEndpointClient> endpoint_client_; | 341 std::unique_ptr<InterfaceEndpointClient> endpoint_client_; |
| 339 std::unique_ptr<Proxy> proxy_; | 342 std::unique_ptr<Proxy> proxy_; |
| 340 | 343 |
| 341 // |router_| (as well as other members above) is not initialized until | 344 // |router_| (as well as other members above) is not initialized until |
| 342 // read/write with the message pipe handle is needed. |handle_| is valid | 345 // read/write with the message pipe handle is needed. |handle_| is valid |
| 343 // between the Bind() call and the initialization of |router_|. | 346 // between the Bind() call and the initialization of |router_|. |
| 344 ScopedMessagePipeHandle handle_; | 347 ScopedMessagePipeHandle handle_; |
| 345 scoped_refptr<base::SingleThreadTaskRunner> runner_; | 348 scoped_refptr<base::SingleThreadTaskRunner> runner_; |
| 346 | 349 |
| 347 uint32_t version_; | 350 uint32_t version_; |
| 348 | 351 |
| 349 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); | 352 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); |
| 350 }; | 353 }; |
| 351 | 354 |
| 352 } // namespace internal | 355 } // namespace internal |
| 353 } // namespace mojo | 356 } // namespace mojo |
| 354 | 357 |
| 355 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ | 358 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ |
| OLD | NEW |