| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 // Processes enqueued tasks (incoming messages and error notifications). | 166 // Processes enqueued tasks (incoming messages and error notifications). |
| 167 // If |force_async| is true, it guarantees not to call any | 167 // If |force_async| is true, it guarantees not to call any |
| 168 // InterfaceEndpointClient methods directly. | 168 // InterfaceEndpointClient methods directly. |
| 169 // | 169 // |
| 170 // Note: Because calling into InterfaceEndpointClient may lead to destruction | 170 // Note: Because calling into InterfaceEndpointClient may lead to destruction |
| 171 // of this object, if |force_async| is set to false, the caller needs to hold | 171 // of this object, if |force_async| is set to false, the caller needs to hold |
| 172 // on to a ref outside of |lock_| before calling this method. | 172 // on to a ref outside of |lock_| before calling this method. |
| 173 void ProcessTasks(bool force_async); | 173 void ProcessTasks(bool force_async); |
| 174 | 174 |
| 175 // Returns true to indicate that |task| has been processed. Otherwise the task | 175 // Returns true to indicate that |task|/|message| has been processed. |
| 176 // will be added back to the front of the queue. | |
| 177 bool ProcessNotifyErrorTask(Task* task, bool force_async); | 176 bool ProcessNotifyErrorTask(Task* task, bool force_async); |
| 178 bool ProcessIncomingMessageTask(Task* task, bool force_async); | 177 bool ProcessIncomingMessage(Message* message, bool force_async); |
| 179 | 178 |
| 180 void LockAndCallProcessTasks(); | 179 void LockAndCallProcessTasks(); |
| 181 | 180 |
| 182 // Updates the state of |endpoint|. If both the endpoint and its peer have | 181 // Updates the state of |endpoint|. If both the endpoint and its peer have |
| 183 // been closed, removes it from |endpoints_|. | 182 // been closed, removes it from |endpoints_|. |
| 184 // NOTE: The method may invalidate |endpoint|. | 183 // NOTE: The method may invalidate |endpoint|. |
| 185 enum EndpointStateUpdateType { ENDPOINT_CLOSED, PEER_ENDPOINT_CLOSED }; | 184 enum EndpointStateUpdateType { ENDPOINT_CLOSED, PEER_ENDPOINT_CLOSED }; |
| 186 void UpdateEndpointStateMayRemove(InterfaceEndpoint* endpoint, | 185 void UpdateEndpointStateMayRemove(InterfaceEndpoint* endpoint, |
| 187 EndpointStateUpdateType type); | 186 EndpointStateUpdateType type); |
| 188 | 187 |
| 189 void RaiseErrorInNonTestingMode(); | 188 void RaiseErrorInNonTestingMode(); |
| 190 | 189 |
| 190 InterfaceEndpoint* FindOrInsertEndpoint(InterfaceId id, bool* inserted); |
| 191 |
| 191 // Whether to set the namespace bit when generating interface IDs. Please see | 192 // Whether to set the namespace bit when generating interface IDs. Please see |
| 192 // comments of kInterfaceIdNamespaceMask. | 193 // comments of kInterfaceIdNamespaceMask. |
| 193 const bool set_interface_id_namespace_bit_; | 194 const bool set_interface_id_namespace_bit_; |
| 194 | 195 |
| 195 MessageHeaderValidator header_validator_; | 196 MessageHeaderValidator header_validator_; |
| 196 Connector connector_; | 197 Connector connector_; |
| 197 bool encountered_error_; | 198 bool encountered_error_; |
| 198 | 199 |
| 199 base::ThreadChecker thread_checker_; | 200 base::ThreadChecker thread_checker_; |
| 200 | 201 |
| 201 // Protects the following members. | 202 // Protects the following members. |
| 202 mutable base::Lock lock_; | 203 mutable base::Lock lock_; |
| 203 PipeControlMessageHandler control_message_handler_; | 204 PipeControlMessageHandler control_message_handler_; |
| 204 PipeControlMessageProxy control_message_proxy_; | 205 PipeControlMessageProxy control_message_proxy_; |
| 205 | 206 |
| 206 std::map<InterfaceId, scoped_refptr<InterfaceEndpoint>> endpoints_; | 207 std::map<InterfaceId, scoped_refptr<InterfaceEndpoint>> endpoints_; |
| 207 uint32_t next_interface_id_value_; | 208 uint32_t next_interface_id_value_; |
| 208 | 209 |
| 209 std::deque<scoped_ptr<Task>> tasks_; | 210 std::deque<scoped_ptr<Task>> tasks_; |
| 210 | 211 |
| 212 bool posted_to_process_tasks_; |
| 213 |
| 211 bool testing_mode_; | 214 bool testing_mode_; |
| 212 | 215 |
| 213 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); | 216 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); |
| 214 }; | 217 }; |
| 215 | 218 |
| 216 } // namespace internal | 219 } // namespace internal |
| 217 } // namespace mojo | 220 } // namespace mojo |
| 218 | 221 |
| 219 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 222 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| OLD | NEW |