| 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> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 // MultiplexRouter supports routing messages for multiple interfaces over a | 41 // MultiplexRouter supports routing messages for multiple interfaces over a |
| 42 // single message pipe. | 42 // single message pipe. |
| 43 // | 43 // |
| 44 // It is created on the thread where the master interface of the message pipe | 44 // It is created on the thread where the master interface of the message pipe |
| 45 // lives. Although it is ref-counted, it is guarateed to be destructed on the | 45 // lives. Although it is ref-counted, it is guarateed to be destructed on the |
| 46 // same thread. | 46 // same thread. |
| 47 // Some public methods are only allowed to be called on the creating thread; | 47 // Some public methods are only allowed to be called on the creating thread; |
| 48 // while the others are safe to call from any threads. Please see the method | 48 // while the others are safe to call from any threads. Please see the method |
| 49 // comments for more details. | 49 // comments for more details. |
| 50 // |
| 51 // NOTE: CloseMessagePipe() or PassMessagePipe() MUST be called on |runner|'s |
| 52 // thread before this object is destroyed. |
| 50 class MultiplexRouter | 53 class MultiplexRouter |
| 51 : public MessageReceiver, | 54 : public MessageReceiver, |
| 52 public AssociatedGroupController, | 55 public AssociatedGroupController, |
| 53 public PipeControlMessageHandlerDelegate { | 56 public PipeControlMessageHandlerDelegate { |
| 54 public: | 57 public: |
| 55 // If |set_interface_id_namespace_bit| is true, the interface IDs generated by | 58 // If |set_interface_id_namespace_bit| is true, the interface IDs generated by |
| 56 // this router will have the highest bit set. | 59 // this router will have the highest bit set. |
| 57 MultiplexRouter(bool set_interface_id_namespace_bit, | 60 MultiplexRouter(bool set_interface_id_namespace_bit, |
| 58 ScopedMessagePipeHandle message_pipe, | 61 ScopedMessagePipeHandle message_pipe, |
| 59 scoped_refptr<base::SingleThreadTaskRunner> runner); | 62 scoped_refptr<base::SingleThreadTaskRunner> runner); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 EndpointStateUpdateType type); | 197 EndpointStateUpdateType type); |
| 195 | 198 |
| 196 void RaiseErrorInNonTestingMode(); | 199 void RaiseErrorInNonTestingMode(); |
| 197 | 200 |
| 198 InterfaceEndpoint* FindOrInsertEndpoint(InterfaceId id, bool* inserted); | 201 InterfaceEndpoint* FindOrInsertEndpoint(InterfaceId id, bool* inserted); |
| 199 | 202 |
| 200 // Whether to set the namespace bit when generating interface IDs. Please see | 203 // Whether to set the namespace bit when generating interface IDs. Please see |
| 201 // comments of kInterfaceIdNamespaceMask. | 204 // comments of kInterfaceIdNamespaceMask. |
| 202 const bool set_interface_id_namespace_bit_; | 205 const bool set_interface_id_namespace_bit_; |
| 203 | 206 |
| 207 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 208 |
| 204 MessageHeaderValidator header_validator_; | 209 MessageHeaderValidator header_validator_; |
| 205 Connector connector_; | 210 Connector connector_; |
| 206 | 211 |
| 207 base::ThreadChecker thread_checker_; | 212 base::ThreadChecker thread_checker_; |
| 208 | 213 |
| 209 // Protects the following members. | 214 // Protects the following members. |
| 210 mutable base::Lock lock_; | 215 mutable base::Lock lock_; |
| 211 PipeControlMessageHandler control_message_handler_; | 216 PipeControlMessageHandler control_message_handler_; |
| 212 PipeControlMessageProxy control_message_proxy_; | 217 PipeControlMessageProxy control_message_proxy_; |
| 213 | 218 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 227 | 232 |
| 228 bool testing_mode_; | 233 bool testing_mode_; |
| 229 | 234 |
| 230 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); | 235 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); |
| 231 }; | 236 }; |
| 232 | 237 |
| 233 } // namespace internal | 238 } // namespace internal |
| 234 } // namespace mojo | 239 } // namespace mojo |
| 235 | 240 |
| 236 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 241 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| OLD | NEW |