| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 DCHECK(thread_checker_.CalledOnValidThread()); | 147 DCHECK(thread_checker_.CalledOnValidThread()); |
| 148 return connector_.handle(); | 148 return connector_.handle(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool SimulateReceivingMessageForTesting(Message* message) { | 151 bool SimulateReceivingMessageForTesting(Message* message) { |
| 152 return filters_.Accept(message); | 152 return filters_.Accept(message); |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 class InterfaceEndpoint; | 156 class InterfaceEndpoint; |
| 157 class IncomingMessageWrapper; | 157 class MessageWrapper; |
| 158 struct Task; | 158 struct Task; |
| 159 | 159 |
| 160 ~MultiplexRouter() override; | 160 ~MultiplexRouter() override; |
| 161 | 161 |
| 162 // MessageReceiver implementation: | 162 // MessageReceiver implementation: |
| 163 bool Accept(Message* message) override; | 163 bool Accept(Message* message) override; |
| 164 | 164 |
| 165 // PipeControlMessageHandlerDelegate implementation: | 165 // PipeControlMessageHandlerDelegate implementation: |
| 166 bool OnPeerAssociatedEndpointClosed( | 166 bool OnPeerAssociatedEndpointClosed( |
| 167 InterfaceId id, | 167 InterfaceId id, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // This method is only used by enpoints during sync watching. Therefore, not | 202 // This method is only used by enpoints during sync watching. Therefore, not |
| 203 // all sync messages are handled by it. | 203 // all sync messages are handled by it. |
| 204 bool ProcessFirstSyncMessageForEndpoint(InterfaceId id); | 204 bool ProcessFirstSyncMessageForEndpoint(InterfaceId id); |
| 205 | 205 |
| 206 // Returns true to indicate that |task|/|message| has been processed. | 206 // Returns true to indicate that |task|/|message| has been processed. |
| 207 bool ProcessNotifyErrorTask( | 207 bool ProcessNotifyErrorTask( |
| 208 Task* task, | 208 Task* task, |
| 209 ClientCallBehavior client_call_behavior, | 209 ClientCallBehavior client_call_behavior, |
| 210 base::SingleThreadTaskRunner* current_task_runner); | 210 base::SingleThreadTaskRunner* current_task_runner); |
| 211 bool ProcessIncomingMessage( | 211 bool ProcessIncomingMessage( |
| 212 IncomingMessageWrapper* message_wrapper, | 212 Message* message, |
| 213 ClientCallBehavior client_call_behavior, | 213 ClientCallBehavior client_call_behavior, |
| 214 base::SingleThreadTaskRunner* current_task_runner); | 214 base::SingleThreadTaskRunner* current_task_runner); |
| 215 | 215 |
| 216 void MaybePostToProcessTasks(base::SingleThreadTaskRunner* task_runner); | 216 void MaybePostToProcessTasks(base::SingleThreadTaskRunner* task_runner); |
| 217 void LockAndCallProcessTasks(); | 217 void LockAndCallProcessTasks(); |
| 218 | 218 |
| 219 // Updates the state of |endpoint|. If both the endpoint and its peer have | 219 // Updates the state of |endpoint|. If both the endpoint and its peer have |
| 220 // been closed, removes it from |endpoints_|. | 220 // been closed, removes it from |endpoints_|. |
| 221 // NOTE: The method may invalidate |endpoint|. | 221 // NOTE: The method may invalidate |endpoint|. |
| 222 enum EndpointStateUpdateType { ENDPOINT_CLOSED, PEER_ENDPOINT_CLOSED }; | 222 enum EndpointStateUpdateType { ENDPOINT_CLOSED, PEER_ENDPOINT_CLOSED }; |
| 223 void UpdateEndpointStateMayRemove(InterfaceEndpoint* endpoint, | 223 void UpdateEndpointStateMayRemove(InterfaceEndpoint* endpoint, |
| 224 EndpointStateUpdateType type); | 224 EndpointStateUpdateType type); |
| 225 | 225 |
| 226 void RaiseErrorInNonTestingMode(); | 226 void RaiseErrorInNonTestingMode(); |
| 227 | 227 |
| 228 InterfaceEndpoint* FindOrInsertEndpoint(InterfaceId id, bool* inserted); | 228 InterfaceEndpoint* FindOrInsertEndpoint(InterfaceId id, bool* inserted); |
| 229 InterfaceEndpoint* FindEndpoint(InterfaceId id); |
| 229 | 230 |
| 230 void AssertLockAcquired(); | 231 void AssertLockAcquired(); |
| 231 | 232 |
| 232 // Whether to set the namespace bit when generating interface IDs. Please see | 233 // Whether to set the namespace bit when generating interface IDs. Please see |
| 233 // comments of kInterfaceIdNamespaceMask. | 234 // comments of kInterfaceIdNamespaceMask. |
| 234 const bool set_interface_id_namespace_bit_; | 235 const bool set_interface_id_namespace_bit_; |
| 235 | 236 |
| 236 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 237 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 237 | 238 |
| 238 // Owned by |filters_| below. | 239 // Owned by |filters_| below. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 267 | 268 |
| 268 bool testing_mode_; | 269 bool testing_mode_; |
| 269 | 270 |
| 270 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); | 271 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); |
| 271 }; | 272 }; |
| 272 | 273 |
| 273 } // namespace internal | 274 } // namespace internal |
| 274 } // namespace mojo | 275 } // namespace mojo |
| 275 | 276 |
| 276 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 277 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| OLD | NEW |