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 | |
140 // Called to inform this node that communication with another node is lost | 125 // Called to inform this node that communication with another node is lost |
141 // indefinitely. This triggers cleanup of ports bound to this node. | 126 // indefinitely. This triggers cleanup of ports bound to this node. |
142 int LostConnectionToNode(const NodeName& node_name); | 127 int LostConnectionToNode(const NodeName& node_name); |
143 | 128 |
144 private: | 129 private: |
145 int OnUserMessage(ScopedMessage message); | 130 int OnUserMessage(ScopedMessage message); |
146 int OnPortAccepted(const PortName& port_name); | 131 int OnPortAccepted(const PortName& port_name); |
147 int OnObserveProxy(const PortName& port_name, | 132 int OnObserveProxy(const PortName& port_name, |
148 const ObserveProxyEventData& event); | 133 const ObserveProxyEventData& event); |
149 int OnObserveProxyAck(const PortName& port_name, uint64_t last_sequence_num); | 134 int OnObserveProxyAck(const PortName& port_name, uint64_t last_sequence_num); |
150 int OnObserveClosure(const PortName& port_name, uint64_t last_sequence_num); | 135 int OnObserveClosure(const PortName& port_name, uint64_t last_sequence_num); |
151 int OnMergePort(const PortName& port_name, const MergePortEventData& event); | |
152 | 136 |
153 int AddPortWithName(const PortName& port_name, | 137 int AddPortWithName(const PortName& port_name, |
154 const scoped_refptr<Port>& port); | 138 const scoped_refptr<Port>& port); |
155 void ErasePort(const PortName& port_name); | 139 void ErasePort(const PortName& port_name); |
156 void ErasePort_Locked(const PortName& port_name); | 140 void ErasePort_Locked(const PortName& port_name); |
157 scoped_refptr<Port> GetPort(const PortName& port_name); | 141 scoped_refptr<Port> GetPort(const PortName& port_name); |
158 scoped_refptr<Port> GetPort_Locked(const PortName& port_name); | 142 scoped_refptr<Port> GetPort_Locked(const PortName& port_name); |
159 | 143 |
160 void WillSendPort_Locked(Port* port, | 144 void WillSendPort_Locked(Port* port, |
161 const NodeName& to_node_name, | 145 const NodeName& to_node_name, |
162 PortName* port_name, | 146 PortName* port_name, |
163 PortDescriptor* port_descriptor); | 147 PortDescriptor* port_descriptor); |
164 int AcceptPort(const PortName& port_name, | 148 int AcceptPort(const PortName& port_name, |
165 const PortDescriptor& port_descriptor); | 149 const PortDescriptor& port_descriptor); |
166 | 150 |
167 int WillSendMessage_Locked(Port* port, | 151 int WillSendMessage_Locked(Port* port, |
168 const PortName& port_name, | 152 const PortName& port_name, |
169 Message* message); | 153 Message* message); |
170 int BeginProxying_Locked(Port* port, const PortName& port_name); | |
171 int ForwardMessages_Locked(Port* port, const PortName& port_name); | 154 int ForwardMessages_Locked(Port* port, const PortName& port_name); |
172 void InitiateProxyRemoval_Locked(Port* port, const PortName& port_name); | 155 void InitiateProxyRemoval_Locked(Port* port, const PortName& port_name); |
173 void MaybeRemoveProxy_Locked(Port* port, const PortName& port_name); | 156 void MaybeRemoveProxy_Locked(Port* port, const PortName& port_name); |
174 | 157 |
175 ScopedMessage NewInternalMessage_Helper(const PortName& port_name, | 158 ScopedMessage NewInternalMessage_Helper(const PortName& port_name, |
176 const EventType& type, | 159 const EventType& type, |
177 const void* data, | 160 const void* data, |
178 size_t num_data_bytes); | 161 size_t num_data_bytes); |
179 | 162 |
180 ScopedMessage NewInternalMessage(const PortName& port_name, | 163 ScopedMessage NewInternalMessage(const PortName& port_name, |
(...skipping 19 matching lines...) Expand all Loading... |
200 std::unordered_map<PortName, scoped_refptr<Port>> ports_; | 183 std::unordered_map<PortName, scoped_refptr<Port>> ports_; |
201 | 184 |
202 DISALLOW_COPY_AND_ASSIGN(Node); | 185 DISALLOW_COPY_AND_ASSIGN(Node); |
203 }; | 186 }; |
204 | 187 |
205 } // namespace ports | 188 } // namespace ports |
206 } // namespace edk | 189 } // namespace edk |
207 } // namespace mojo | 190 } // namespace mojo |
208 | 191 |
209 #endif // MOJO_EDK_SYSTEM_PORTS_NODE_H_ | 192 #endif // MOJO_EDK_SYSTEM_PORTS_NODE_H_ |
OLD | NEW |