| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // merged (B or C above) has ever been read from or written to directly, and | 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 | 131 // this must ONLY be called on one side of the merge, though it doesn't matter |
| 132 // which side. | 132 // which side. |
| 133 // | 133 // |
| 134 // It is safe for the non-merged peers (A and D above) to be transferred, | 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. | 135 // closed, and/or written to before, during, or after the merge. |
| 136 int MergePorts(const PortRef& port_ref, | 136 int MergePorts(const PortRef& port_ref, |
| 137 const NodeName& destination_node_name, | 137 const NodeName& destination_node_name, |
| 138 const PortName& destination_port_name); | 138 const PortName& destination_port_name); |
| 139 | 139 |
| 140 // Like above but merges two ports local to this node. Because both ports are |
| 141 // local this can also verify that neither port has been written to before the |
| 142 // merge. If this fails for any reason, both ports are closed. Otherwise OK |
| 143 // is returned and the ports' receiving peers are connected to each other. |
| 144 int MergeLocalPorts(const PortRef& port0_ref, const PortRef& port1_ref); |
| 145 |
| 140 // Called to inform this node that communication with another node is lost | 146 // Called to inform this node that communication with another node is lost |
| 141 // indefinitely. This triggers cleanup of ports bound to this node. | 147 // indefinitely. This triggers cleanup of ports bound to this node. |
| 142 int LostConnectionToNode(const NodeName& node_name); | 148 int LostConnectionToNode(const NodeName& node_name); |
| 143 | 149 |
| 144 private: | 150 private: |
| 145 int OnUserMessage(ScopedMessage message); | 151 int OnUserMessage(ScopedMessage message); |
| 146 int OnPortAccepted(const PortName& port_name); | 152 int OnPortAccepted(const PortName& port_name); |
| 147 int OnObserveProxy(const PortName& port_name, | 153 int OnObserveProxy(const PortName& port_name, |
| 148 const ObserveProxyEventData& event); | 154 const ObserveProxyEventData& event); |
| 149 int OnObserveProxyAck(const PortName& port_name, uint64_t last_sequence_num); | 155 int OnObserveProxyAck(const PortName& port_name, uint64_t last_sequence_num); |
| 150 int OnObserveClosure(const PortName& port_name, uint64_t last_sequence_num); | 156 int OnObserveClosure(const PortName& port_name, uint64_t last_sequence_num); |
| 151 int OnMergePort(const PortName& port_name, const MergePortEventData& event); | 157 int OnMergePort(const PortName& port_name, const MergePortEventData& event); |
| 152 | 158 |
| 153 int AddPortWithName(const PortName& port_name, | 159 int AddPortWithName(const PortName& port_name, |
| 154 const scoped_refptr<Port>& port); | 160 const scoped_refptr<Port>& port); |
| 155 void ErasePort(const PortName& port_name); | 161 void ErasePort(const PortName& port_name); |
| 156 void ErasePort_Locked(const PortName& port_name); | 162 void ErasePort_Locked(const PortName& port_name); |
| 157 scoped_refptr<Port> GetPort(const PortName& port_name); | 163 scoped_refptr<Port> GetPort(const PortName& port_name); |
| 158 scoped_refptr<Port> GetPort_Locked(const PortName& port_name); | 164 scoped_refptr<Port> GetPort_Locked(const PortName& port_name); |
| 159 | 165 |
| 166 int MergePorts_Locked(const PortRef& port0_ref, const PortRef& port1_ref); |
| 160 void WillSendPort_Locked(Port* port, | 167 void WillSendPort_Locked(Port* port, |
| 161 const NodeName& to_node_name, | 168 const NodeName& to_node_name, |
| 162 PortName* port_name, | 169 PortName* port_name, |
| 163 PortDescriptor* port_descriptor); | 170 PortDescriptor* port_descriptor); |
| 164 int AcceptPort(const PortName& port_name, | 171 int AcceptPort(const PortName& port_name, |
| 165 const PortDescriptor& port_descriptor); | 172 const PortDescriptor& port_descriptor); |
| 166 | 173 |
| 167 int WillSendMessage_Locked(Port* port, | 174 int WillSendMessage_Locked(Port* port, |
| 168 const PortName& port_name, | 175 const PortName& port_name, |
| 169 Message* message); | 176 Message* message); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 200 std::unordered_map<PortName, scoped_refptr<Port>> ports_; | 207 std::unordered_map<PortName, scoped_refptr<Port>> ports_; |
| 201 | 208 |
| 202 DISALLOW_COPY_AND_ASSIGN(Node); | 209 DISALLOW_COPY_AND_ASSIGN(Node); |
| 203 }; | 210 }; |
| 204 | 211 |
| 205 } // namespace ports | 212 } // namespace ports |
| 206 } // namespace edk | 213 } // namespace edk |
| 207 } // namespace mojo | 214 } // namespace mojo |
| 208 | 215 |
| 209 #endif // MOJO_EDK_SYSTEM_PORTS_NODE_H_ | 216 #endif // MOJO_EDK_SYSTEM_PORTS_NODE_H_ |
| OLD | NEW |