| 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 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" | 5 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 MultiplexRouter::MultiplexRouter( | 284 MultiplexRouter::MultiplexRouter( |
| 285 ScopedMessagePipeHandle message_pipe, | 285 ScopedMessagePipeHandle message_pipe, |
| 286 Config config, | 286 Config config, |
| 287 bool set_interface_id_namesapce_bit, | 287 bool set_interface_id_namesapce_bit, |
| 288 scoped_refptr<base::SingleThreadTaskRunner> runner) | 288 scoped_refptr<base::SingleThreadTaskRunner> runner) |
| 289 : set_interface_id_namespace_bit_(set_interface_id_namesapce_bit), | 289 : set_interface_id_namespace_bit_(set_interface_id_namesapce_bit), |
| 290 task_runner_(runner), | 290 task_runner_(runner), |
| 291 header_validator_(nullptr), | 291 header_validator_(nullptr), |
| 292 filters_(this), | 292 filters_(this), |
| 293 connector_(std::move(message_pipe), | 293 connector_(std::move(message_pipe), |
| 294 config == SINGLE_INTERFACE ? Connector::SINGLE_THREADED_SEND | 294 config == MULTI_INTERFACE ? Connector::MULTI_THREADED_SEND |
| 295 : Connector::MULTI_THREADED_SEND, | 295 : Connector::SINGLE_THREADED_SEND, |
| 296 std::move(runner)), | 296 std::move(runner)), |
| 297 lock_(config == SINGLE_INTERFACE ? nullptr : new base::Lock), | 297 lock_(config == MULTI_INTERFACE ? new base::Lock : nullptr), |
| 298 control_message_handler_(this), | 298 control_message_handler_(this), |
| 299 control_message_proxy_(&connector_), | 299 control_message_proxy_(&connector_), |
| 300 next_interface_id_value_(1), | 300 next_interface_id_value_(1), |
| 301 posted_to_process_tasks_(false), | 301 posted_to_process_tasks_(false), |
| 302 encountered_error_(false), | 302 encountered_error_(false), |
| 303 paused_(false), | 303 paused_(false), |
| 304 testing_mode_(false) { | 304 testing_mode_(false) { |
| 305 DCHECK(task_runner_->BelongsToCurrentThread()); | 305 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 306 // Always participate in sync handle watching, because even if it doesn't | 306 |
| 307 // expect sync requests during sync handle watching, it may still need to | 307 if (config == SINGLE_INTERFACE_WITH_SYNC_METHODS || |
| 308 // dispatch messages to associated endpoints on a different thread. | 308 config == MULTI_INTERFACE) { |
| 309 connector_.AllowWokenUpBySyncWatchOnSameThread(); | 309 // Always participate in sync handle watching in multi-interface mode, |
| 310 // because even if it doesn't expect sync requests during sync handle |
| 311 // watching, it may still need to dispatch messages to associated endpoints |
| 312 // on a different thread. |
| 313 connector_.AllowWokenUpBySyncWatchOnSameThread(); |
| 314 } |
| 310 connector_.set_incoming_receiver(&filters_); | 315 connector_.set_incoming_receiver(&filters_); |
| 311 connector_.set_connection_error_handler( | 316 connector_.set_connection_error_handler( |
| 312 base::Bind(&MultiplexRouter::OnPipeConnectionError, | 317 base::Bind(&MultiplexRouter::OnPipeConnectionError, |
| 313 base::Unretained(this))); | 318 base::Unretained(this))); |
| 314 | 319 |
| 315 std::unique_ptr<MessageHeaderValidator> header_validator = | 320 std::unique_ptr<MessageHeaderValidator> header_validator = |
| 316 base::MakeUnique<MessageHeaderValidator>(); | 321 base::MakeUnique<MessageHeaderValidator>(); |
| 317 header_validator_ = header_validator.get(); | 322 header_validator_ = header_validator.get(); |
| 318 filters_.Append(std::move(header_validator)); | 323 filters_.Append(std::move(header_validator)); |
| 319 } | 324 } |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 899 |
| 895 void MultiplexRouter::AssertLockAcquired() { | 900 void MultiplexRouter::AssertLockAcquired() { |
| 896 #if DCHECK_IS_ON() | 901 #if DCHECK_IS_ON() |
| 897 if (lock_) | 902 if (lock_) |
| 898 lock_->AssertAcquired(); | 903 lock_->AssertAcquired(); |
| 899 #endif | 904 #endif |
| 900 } | 905 } |
| 901 | 906 |
| 902 } // namespace internal | 907 } // namespace internal |
| 903 } // namespace mojo | 908 } // namespace mojo |
| OLD | NEW |