| 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_MULTIPLEX_ROUTER_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/optional.h" |
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 21 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
| 22 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 23 #include "mojo/public/cpp/bindings/associated_group_controller.h" | 24 #include "mojo/public/cpp/bindings/associated_group_controller.h" |
| 24 #include "mojo/public/cpp/bindings/bindings_export.h" | 25 #include "mojo/public/cpp/bindings/bindings_export.h" |
| 25 #include "mojo/public/cpp/bindings/connector.h" | 26 #include "mojo/public/cpp/bindings/connector.h" |
| 26 #include "mojo/public/cpp/bindings/filter_chain.h" | 27 #include "mojo/public/cpp/bindings/filter_chain.h" |
| 27 #include "mojo/public/cpp/bindings/interface_id.h" | 28 #include "mojo/public/cpp/bindings/interface_id.h" |
| 28 #include "mojo/public/cpp/bindings/message_header_validator.h" | 29 #include "mojo/public/cpp/bindings/message_header_validator.h" |
| 29 #include "mojo/public/cpp/bindings/pipe_control_message_handler.h" | 30 #include "mojo/public/cpp/bindings/pipe_control_message_handler.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 236 |
| 236 // Owned by |filters_| below. | 237 // Owned by |filters_| below. |
| 237 MessageHeaderValidator* header_validator_; | 238 MessageHeaderValidator* header_validator_; |
| 238 | 239 |
| 239 FilterChain filters_; | 240 FilterChain filters_; |
| 240 Connector connector_; | 241 Connector connector_; |
| 241 | 242 |
| 242 base::ThreadChecker thread_checker_; | 243 base::ThreadChecker thread_checker_; |
| 243 | 244 |
| 244 // Protects the following members. | 245 // Protects the following members. |
| 245 // Sets to nullptr in Config::SINGLE_INTERFACE* mode. | 246 // Not set in Config::SINGLE_INTERFACE* mode. |
| 246 std::unique_ptr<base::Lock> lock_; | 247 mutable base::Optional<base::Lock> lock_; |
| 247 PipeControlMessageHandler control_message_handler_; | 248 PipeControlMessageHandler control_message_handler_; |
| 248 | 249 |
| 249 // NOTE: It is unsafe to call into this object while holding |lock_|. | 250 // NOTE: It is unsafe to call into this object while holding |lock_|. |
| 250 PipeControlMessageProxy control_message_proxy_; | 251 PipeControlMessageProxy control_message_proxy_; |
| 251 | 252 |
| 252 std::map<InterfaceId, scoped_refptr<InterfaceEndpoint>> endpoints_; | 253 std::map<InterfaceId, scoped_refptr<InterfaceEndpoint>> endpoints_; |
| 253 uint32_t next_interface_id_value_; | 254 uint32_t next_interface_id_value_; |
| 254 | 255 |
| 255 std::deque<std::unique_ptr<Task>> tasks_; | 256 std::deque<std::unique_ptr<Task>> tasks_; |
| 256 // It refers to tasks in |tasks_| and doesn't own any of them. | 257 // It refers to tasks in |tasks_| and doesn't own any of them. |
| 257 std::map<InterfaceId, std::deque<Task*>> sync_message_tasks_; | 258 std::map<InterfaceId, std::deque<Task*>> sync_message_tasks_; |
| 258 | 259 |
| 259 bool posted_to_process_tasks_; | 260 bool posted_to_process_tasks_; |
| 260 scoped_refptr<base::SingleThreadTaskRunner> posted_to_task_runner_; | 261 scoped_refptr<base::SingleThreadTaskRunner> posted_to_task_runner_; |
| 261 | 262 |
| 262 bool encountered_error_; | 263 bool encountered_error_; |
| 263 | 264 |
| 264 bool paused_; | 265 bool paused_; |
| 265 | 266 |
| 266 bool testing_mode_; | 267 bool testing_mode_; |
| 267 | 268 |
| 268 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); | 269 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 } // namespace internal | 272 } // namespace internal |
| 272 } // namespace mojo | 273 } // namespace mojo |
| 273 | 274 |
| 274 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 275 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| OLD | NEW |