Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Side by Side Diff: mojo/edk/system/node_controller.h

Issue 2043713004: Mojo: Add NotifyBadMessage API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no bindings Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/node_channel.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CONTROLLER_H_ 5 #ifndef MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_
6 #define MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ 6 #define MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void CreateMachPortRelay(base::PortProvider* port_provider); 67 void CreateMachPortRelay(base::PortProvider* port_provider);
68 #endif 68 #endif
69 69
70 // Called exactly once, shortly after construction, and before any other 70 // Called exactly once, shortly after construction, and before any other
71 // methods are called on this object. 71 // methods are called on this object.
72 void SetIOTaskRunner(scoped_refptr<base::TaskRunner> io_task_runner); 72 void SetIOTaskRunner(scoped_refptr<base::TaskRunner> io_task_runner);
73 73
74 // Connects this node to a child node. This node will initiate a handshake. 74 // Connects this node to a child node. This node will initiate a handshake.
75 void ConnectToChild(base::ProcessHandle process_handle, 75 void ConnectToChild(base::ProcessHandle process_handle,
76 ScopedPlatformHandle platform_handle, 76 ScopedPlatformHandle platform_handle,
77 const std::string& child_token); 77 const std::string& child_token,
78 const ProcessErrorCallback& process_error_callback);
78 79
79 // Closes all reserved ports which associated with the child process 80 // Closes all reserved ports which associated with the child process
80 // |child_token|. 81 // |child_token|.
81 void CloseChildPorts(const std::string& child_token); 82 void CloseChildPorts(const std::string& child_token);
82 83
83 // Connects this node to a parent node. The parent node will initiate a 84 // Connects this node to a parent node. The parent node will initiate a
84 // handshake. 85 // handshake.
85 void ConnectToParent(ScopedPlatformHandle platform_handle); 86 void ConnectToParent(ScopedPlatformHandle platform_handle);
86 87
87 // Sets a port's observer. If |observer| is null the port's current observer 88 // Sets a port's observer. If |observer| is null the port's current observer
(...skipping 26 matching lines...) Expand all
114 115
115 // Request that the Node be shut down cleanly. This may take an arbitrarily 116 // Request that the Node be shut down cleanly. This may take an arbitrarily
116 // long time to complete, at which point |callback| will be called. 117 // long time to complete, at which point |callback| will be called.
117 // 118 //
118 // Note that while it is safe to continue using the NodeController's public 119 // Note that while it is safe to continue using the NodeController's public
119 // interface after requesting shutdown, you do so at your own risk and there 120 // interface after requesting shutdown, you do so at your own risk and there
120 // is NO guarantee that new messages will be sent or ports will complete 121 // is NO guarantee that new messages will be sent or ports will complete
121 // transfer. 122 // transfer.
122 void RequestShutdown(const base::Closure& callback); 123 void RequestShutdown(const base::Closure& callback);
123 124
125 // Notifies the NodeController that we received a bad message from the given
126 // node.
127 void NotifyBadMessageFrom(const ports::NodeName& source_node,
128 const std::string& error);
129
124 private: 130 private:
125 friend Core; 131 friend Core;
126 132
127 using NodeMap = std::unordered_map<ports::NodeName, 133 using NodeMap = std::unordered_map<ports::NodeName,
128 scoped_refptr<NodeChannel>>; 134 scoped_refptr<NodeChannel>>;
129 using OutgoingMessageQueue = std::queue<Channel::MessagePtr>; 135 using OutgoingMessageQueue = std::queue<Channel::MessagePtr>;
130 136
131 struct ReservedPort { 137 struct ReservedPort {
132 ports::PortRef port; 138 ports::PortRef port;
133 const std::string child_token; 139 const std::string child_token;
134 }; 140 };
135 141
136 void ConnectToChildOnIOThread(base::ProcessHandle process_handle, 142 void ConnectToChildOnIOThread(
137 ScopedPlatformHandle platform_handle, 143 base::ProcessHandle process_handle,
138 ports::NodeName token); 144 ScopedPlatformHandle platform_handle,
145 ports::NodeName token,
146 const ProcessErrorCallback& process_error_callback);
139 void ConnectToParentOnIOThread(ScopedPlatformHandle platform_handle); 147 void ConnectToParentOnIOThread(ScopedPlatformHandle platform_handle);
140 148
141 scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name); 149 scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name);
142 scoped_refptr<NodeChannel> GetParentChannel(); 150 scoped_refptr<NodeChannel> GetParentChannel();
143 scoped_refptr<NodeChannel> GetBrokerChannel(); 151 scoped_refptr<NodeChannel> GetBrokerChannel();
144 152
145 void AddPeer(const ports::NodeName& name, 153 void AddPeer(const ports::NodeName& name,
146 scoped_refptr<NodeChannel> channel, 154 scoped_refptr<NodeChannel> channel,
147 bool start_channel); 155 bool start_channel);
148 void DropPeer(const ports::NodeName& name); 156 void DropPeer(const ports::NodeName& name);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void OnRequestIntroduction(const ports::NodeName& from_node, 191 void OnRequestIntroduction(const ports::NodeName& from_node,
184 const ports::NodeName& name) override; 192 const ports::NodeName& name) override;
185 void OnIntroduce(const ports::NodeName& from_node, 193 void OnIntroduce(const ports::NodeName& from_node,
186 const ports::NodeName& name, 194 const ports::NodeName& name,
187 ScopedPlatformHandle channel_handle) override; 195 ScopedPlatformHandle channel_handle) override;
188 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) 196 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
189 void OnRelayPortsMessage(const ports::NodeName& from_node, 197 void OnRelayPortsMessage(const ports::NodeName& from_node,
190 base::ProcessHandle from_process, 198 base::ProcessHandle from_process,
191 const ports::NodeName& destination, 199 const ports::NodeName& destination,
192 Channel::MessagePtr message) override; 200 Channel::MessagePtr message) override;
201 void OnPortsMessageFromRelay(const ports::NodeName& from_node,
202 const ports::NodeName& source_node,
203 Channel::MessagePtr message) override;
193 #endif 204 #endif
194 void OnChannelError(const ports::NodeName& from_node) override; 205 void OnChannelError(const ports::NodeName& from_node) override;
195 #if defined(OS_MACOSX) && !defined(OS_IOS) 206 #if defined(OS_MACOSX) && !defined(OS_IOS)
196 MachPortRelay* GetMachPortRelay() override; 207 MachPortRelay* GetMachPortRelay() override;
197 #endif 208 #endif
198 209
199 // Marks this NodeController for destruction when the IO thread shuts down. 210 // Marks this NodeController for destruction when the IO thread shuts down.
200 // This is used in case Core is torn down before the IO thread. Must only be 211 // This is used in case Core is torn down before the IO thread. Must only be
201 // called on the IO thread. 212 // called on the IO thread.
202 void DestroyOnIOThreadShutdown(); 213 void DestroyOnIOThreadShutdown();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 std::unique_ptr<MachPortRelay> mach_port_relay_; 308 std::unique_ptr<MachPortRelay> mach_port_relay_;
298 #endif 309 #endif
299 310
300 DISALLOW_COPY_AND_ASSIGN(NodeController); 311 DISALLOW_COPY_AND_ASSIGN(NodeController);
301 }; 312 };
302 313
303 } // namespace edk 314 } // namespace edk
304 } // namespace mojo 315 } // namespace mojo
305 316
306 #endif // MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ 317 #endif // MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/node_channel.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698