| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_EDK_SYSTEM_NODE_CHANNEL_H_ | 5 #ifndef MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ |
| 6 #define MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ | 6 #define MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "mojo/edk/embedder/connection_param.h" |
| 19 #include "mojo/edk/embedder/embedder.h" | 20 #include "mojo/edk/embedder/embedder.h" |
| 20 #include "mojo/edk/embedder/platform_handle_vector.h" | 21 #include "mojo/edk/embedder/platform_handle_vector.h" |
| 21 #include "mojo/edk/embedder/scoped_platform_handle.h" | 22 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 22 #include "mojo/edk/system/channel.h" | 23 #include "mojo/edk/system/channel.h" |
| 23 #include "mojo/edk/system/ports/name.h" | 24 #include "mojo/edk/system/ports/name.h" |
| 24 | 25 |
| 25 #if defined(OS_MACOSX) && !defined(OS_IOS) | 26 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 26 #include "mojo/edk/system/mach_port_relay.h" | 27 #include "mojo/edk/system/mach_port_relay.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 virtual void OnChannelError(const ports::NodeName& node, | 84 virtual void OnChannelError(const ports::NodeName& node, |
| 84 NodeChannel* channel) = 0; | 85 NodeChannel* channel) = 0; |
| 85 | 86 |
| 86 #if defined(OS_MACOSX) && !defined(OS_IOS) | 87 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 87 virtual MachPortRelay* GetMachPortRelay() = 0; | 88 virtual MachPortRelay* GetMachPortRelay() = 0; |
| 88 #endif | 89 #endif |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 static scoped_refptr<NodeChannel> Create( | 92 static scoped_refptr<NodeChannel> Create( |
| 92 Delegate* delegate, | 93 Delegate* delegate, |
| 93 ScopedPlatformHandle platform_handle, | 94 ConnectionParam connection_param, |
| 94 scoped_refptr<base::TaskRunner> io_task_runner, | 95 scoped_refptr<base::TaskRunner> io_task_runner, |
| 95 const ProcessErrorCallback& process_error_callback); | 96 const ProcessErrorCallback& process_error_callback); |
| 96 | 97 |
| 97 static Channel::MessagePtr CreatePortsMessage(size_t payload_size, | 98 static Channel::MessagePtr CreatePortsMessage(size_t payload_size, |
| 98 void** payload, | 99 void** payload, |
| 99 size_t num_handles); | 100 size_t num_handles); |
| 100 | 101 |
| 101 static void GetPortsMessageData(Channel::Message* message, void** data, | 102 static void GetPortsMessageData(Channel::Message* message, void** data, |
| 102 size_t* num_data_bytes); | 103 size_t* num_data_bytes); |
| 103 | 104 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 #endif | 161 #endif |
| 161 | 162 |
| 162 private: | 163 private: |
| 163 friend class base::RefCountedThreadSafe<NodeChannel>; | 164 friend class base::RefCountedThreadSafe<NodeChannel>; |
| 164 | 165 |
| 165 using PendingMessageQueue = std::queue<Channel::MessagePtr>; | 166 using PendingMessageQueue = std::queue<Channel::MessagePtr>; |
| 166 using PendingRelayMessageQueue = | 167 using PendingRelayMessageQueue = |
| 167 std::queue<std::pair<ports::NodeName, Channel::MessagePtr>>; | 168 std::queue<std::pair<ports::NodeName, Channel::MessagePtr>>; |
| 168 | 169 |
| 169 NodeChannel(Delegate* delegate, | 170 NodeChannel(Delegate* delegate, |
| 170 ScopedPlatformHandle platform_handle, | 171 ConnectionParam connection_param, |
| 171 scoped_refptr<base::TaskRunner> io_task_runner, | 172 scoped_refptr<base::TaskRunner> io_task_runner, |
| 172 const ProcessErrorCallback& process_error_callback); | 173 const ProcessErrorCallback& process_error_callback); |
| 173 ~NodeChannel() override; | 174 ~NodeChannel() override; |
| 174 | 175 |
| 175 // Channel::Delegate: | 176 // Channel::Delegate: |
| 176 void OnChannelMessage(const void* payload, | 177 void OnChannelMessage(const void* payload, |
| 177 size_t payload_size, | 178 size_t payload_size, |
| 178 ScopedPlatformHandleVectorPtr handles) override; | 179 ScopedPlatformHandleVectorPtr handles) override; |
| 179 void OnChannelError() override; | 180 void OnChannelError() override; |
| 180 | 181 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 209 PendingRelayMessageQueue pending_relay_messages_; | 210 PendingRelayMessageQueue pending_relay_messages_; |
| 210 #endif | 211 #endif |
| 211 | 212 |
| 212 DISALLOW_COPY_AND_ASSIGN(NodeChannel); | 213 DISALLOW_COPY_AND_ASSIGN(NodeChannel); |
| 213 }; | 214 }; |
| 214 | 215 |
| 215 } // namespace edk | 216 } // namespace edk |
| 216 } // namespace mojo | 217 } // namespace mojo |
| 217 | 218 |
| 218 #endif // MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ | 219 #endif // MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ |
| OLD | NEW |