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_PORTS_NODE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_PORTS_NODE_H_ |
6 #define MOJO_EDK_SYSTEM_PORTS_NODE_H_ | 6 #define MOJO_EDK_SYSTEM_PORTS_NODE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // notification may arrive synchronously (via PortStatusChanged() on the | 115 // notification may arrive synchronously (via PortStatusChanged() on the |
116 // delegate) if the peer is local to this Node. | 116 // delegate) if the peer is local to this Node. |
117 // | 117 // |
118 // If send fails for any reason, |message| is left unchanged. On success, | 118 // If send fails for any reason, |message| is left unchanged. On success, |
119 // ownserhip is transferred and |message| is reset. | 119 // ownserhip is transferred and |message| is reset. |
120 int SendMessage(const PortRef& port_ref, ScopedMessage* message); | 120 int SendMessage(const PortRef& port_ref, ScopedMessage* message); |
121 | 121 |
122 // Corresponding to NodeDelegate::ForwardMessage. | 122 // Corresponding to NodeDelegate::ForwardMessage. |
123 int AcceptMessage(ScopedMessage message); | 123 int AcceptMessage(ScopedMessage message); |
124 | 124 |
| 125 // Called to merge two ports with each other. If you have two independent |
| 126 // port pairs A <=> B and C <=> D, the net result of merging B and C is a |
| 127 // single connected port pair A <=> D. |
| 128 // |
| 129 // Note that the behavior of this operation is undefined if either port to be |
| 130 // merged (B or C above) has ever been read from or written to directly, and |
| 131 // this must ONLY be called on one side of the merge, though it doesn't matter |
| 132 // which side. |
| 133 // |
| 134 // It is safe for the non-merged peers (A and D above) to be transferred, |
| 135 // closed, and/or written to before, during, or after the merge. |
| 136 int MergePorts(const PortRef& port_ref, |
| 137 const NodeName& destination_node_name, |
| 138 const PortName& destination_port_name); |
| 139 |
125 // Called to inform this node that communication with another node is lost | 140 // Called to inform this node that communication with another node is lost |
126 // indefinitely. This triggers cleanup of ports bound to this node. | 141 // indefinitely. This triggers cleanup of ports bound to this node. |
127 int LostConnectionToNode(const NodeName& node_name); | 142 int LostConnectionToNode(const NodeName& node_name); |
128 | 143 |
129 private: | 144 private: |
130 int OnUserMessage(ScopedMessage message); | 145 int OnUserMessage(ScopedMessage message); |
131 int OnPortAccepted(const PortName& port_name); | 146 int OnPortAccepted(const PortName& port_name); |
132 int OnObserveProxy(const PortName& port_name, | 147 int OnObserveProxy(const PortName& port_name, |
133 const ObserveProxyEventData& event); | 148 const ObserveProxyEventData& event); |
134 int OnObserveProxyAck(const PortName& port_name, uint64_t last_sequence_num); | 149 int OnObserveProxyAck(const PortName& port_name, uint64_t last_sequence_num); |
135 int OnObserveClosure(const PortName& port_name, uint64_t last_sequence_num); | 150 int OnObserveClosure(const PortName& port_name, uint64_t last_sequence_num); |
| 151 int OnMergePort(const PortName& port_name, const MergePortEventData& event); |
136 | 152 |
137 int AddPortWithName(const PortName& port_name, | 153 int AddPortWithName(const PortName& port_name, |
138 const scoped_refptr<Port>& port); | 154 const scoped_refptr<Port>& port); |
139 void ErasePort(const PortName& port_name); | 155 void ErasePort(const PortName& port_name); |
140 void ErasePort_Locked(const PortName& port_name); | 156 void ErasePort_Locked(const PortName& port_name); |
141 scoped_refptr<Port> GetPort(const PortName& port_name); | 157 scoped_refptr<Port> GetPort(const PortName& port_name); |
142 scoped_refptr<Port> GetPort_Locked(const PortName& port_name); | 158 scoped_refptr<Port> GetPort_Locked(const PortName& port_name); |
143 | 159 |
144 void WillSendPort_Locked(Port* port, | 160 void WillSendPort_Locked(Port* port, |
145 const NodeName& to_node_name, | 161 const NodeName& to_node_name, |
146 PortName* port_name, | 162 PortName* port_name, |
147 PortDescriptor* port_descriptor); | 163 PortDescriptor* port_descriptor); |
148 int AcceptPort(const PortName& port_name, | 164 int AcceptPort(const PortName& port_name, |
149 const PortDescriptor& port_descriptor); | 165 const PortDescriptor& port_descriptor); |
150 | 166 |
151 int WillSendMessage_Locked(Port* port, | 167 int WillSendMessage_Locked(Port* port, |
152 const PortName& port_name, | 168 const PortName& port_name, |
153 Message* message); | 169 Message* message); |
| 170 int BeginProxying_Locked(Port* port, const PortName& port_name); |
154 int ForwardMessages_Locked(Port* port, const PortName& port_name); | 171 int ForwardMessages_Locked(Port* port, const PortName& port_name); |
155 void InitiateProxyRemoval_Locked(Port* port, const PortName& port_name); | 172 void InitiateProxyRemoval_Locked(Port* port, const PortName& port_name); |
156 void MaybeRemoveProxy_Locked(Port* port, const PortName& port_name); | 173 void MaybeRemoveProxy_Locked(Port* port, const PortName& port_name); |
157 | 174 |
158 ScopedMessage NewInternalMessage_Helper(const PortName& port_name, | 175 ScopedMessage NewInternalMessage_Helper(const PortName& port_name, |
159 const EventType& type, | 176 const EventType& type, |
160 const void* data, | 177 const void* data, |
161 size_t num_data_bytes); | 178 size_t num_data_bytes); |
162 | 179 |
163 ScopedMessage NewInternalMessage(const PortName& port_name, | 180 ScopedMessage NewInternalMessage(const PortName& port_name, |
(...skipping 19 matching lines...) Expand all Loading... |
183 std::unordered_map<PortName, scoped_refptr<Port>> ports_; | 200 std::unordered_map<PortName, scoped_refptr<Port>> ports_; |
184 | 201 |
185 DISALLOW_COPY_AND_ASSIGN(Node); | 202 DISALLOW_COPY_AND_ASSIGN(Node); |
186 }; | 203 }; |
187 | 204 |
188 } // namespace ports | 205 } // namespace ports |
189 } // namespace edk | 206 } // namespace edk |
190 } // namespace mojo | 207 } // namespace mojo |
191 | 208 |
192 #endif // MOJO_EDK_SYSTEM_PORTS_NODE_H_ | 209 #endif // MOJO_EDK_SYSTEM_PORTS_NODE_H_ |
OLD | NEW |