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

Side by Side Diff: mojo/edk/system/core.cc

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/core.h ('k') | mojo/edk/system/message_for_transit.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "mojo/edk/system/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "mojo/edk/embedder/platform_shared_buffer.h" 23 #include "mojo/edk/embedder/platform_shared_buffer.h"
24 #include "mojo/edk/system/async_waiter.h" 24 #include "mojo/edk/system/async_waiter.h"
25 #include "mojo/edk/system/channel.h" 25 #include "mojo/edk/system/channel.h"
26 #include "mojo/edk/system/configuration.h" 26 #include "mojo/edk/system/configuration.h"
27 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" 27 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
28 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" 28 #include "mojo/edk/system/data_pipe_producer_dispatcher.h"
29 #include "mojo/edk/system/handle_signals_state.h" 29 #include "mojo/edk/system/handle_signals_state.h"
30 #include "mojo/edk/system/message_for_transit.h" 30 #include "mojo/edk/system/message_for_transit.h"
31 #include "mojo/edk/system/message_pipe_dispatcher.h" 31 #include "mojo/edk/system/message_pipe_dispatcher.h"
32 #include "mojo/edk/system/platform_handle_dispatcher.h" 32 #include "mojo/edk/system/platform_handle_dispatcher.h"
33 #include "mojo/edk/system/ports/name.h"
33 #include "mojo/edk/system/ports/node.h" 34 #include "mojo/edk/system/ports/node.h"
34 #include "mojo/edk/system/remote_message_pipe_bootstrap.h" 35 #include "mojo/edk/system/remote_message_pipe_bootstrap.h"
35 #include "mojo/edk/system/request_context.h" 36 #include "mojo/edk/system/request_context.h"
36 #include "mojo/edk/system/shared_buffer_dispatcher.h" 37 #include "mojo/edk/system/shared_buffer_dispatcher.h"
37 #include "mojo/edk/system/wait_set_dispatcher.h" 38 #include "mojo/edk/system/wait_set_dispatcher.h"
38 #include "mojo/edk/system/waiter.h" 39 #include "mojo/edk/system/waiter.h"
39 40
40 namespace mojo { 41 namespace mojo {
41 namespace edk { 42 namespace edk {
42 43
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return node_controller_.get(); 163 return node_controller_.get();
163 } 164 }
164 165
165 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { 166 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) {
166 base::AutoLock lock(handles_lock_); 167 base::AutoLock lock(handles_lock_);
167 return handles_.GetDispatcher(handle); 168 return handles_.GetDispatcher(handle);
168 } 169 }
169 170
170 void Core::AddChild(base::ProcessHandle process_handle, 171 void Core::AddChild(base::ProcessHandle process_handle,
171 ScopedPlatformHandle platform_handle, 172 ScopedPlatformHandle platform_handle,
172 const std::string& child_token) { 173 const std::string& child_token,
174 const ProcessErrorCallback& process_error_callback) {
173 GetNodeController()->ConnectToChild(process_handle, 175 GetNodeController()->ConnectToChild(process_handle,
174 std::move(platform_handle), 176 std::move(platform_handle),
175 child_token); 177 child_token,
178 process_error_callback);
176 } 179 }
177 180
178 void Core::ChildLaunchFailed(const std::string& child_token) { 181 void Core::ChildLaunchFailed(const std::string& child_token) {
179 RequestContext request_context; 182 RequestContext request_context;
180 GetNodeController()->CloseChildPorts(child_token); 183 GetNodeController()->CloseChildPorts(child_token);
181 } 184 }
182 185
183 void Core::InitChild(ScopedPlatformHandle platform_handle) { 186 void Core::InitChild(ScopedPlatformHandle platform_handle) {
184 GetNodeController()->ConnectToParent(std::move(platform_handle)); 187 GetNodeController()->ConnectToParent(std::move(platform_handle));
185 } 188 }
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 static_cast<MessagePipeDispatcher*>(dispatcher0.get()); 748 static_cast<MessagePipeDispatcher*>(dispatcher0.get());
746 MessagePipeDispatcher* mpd1 = 749 MessagePipeDispatcher* mpd1 =
747 static_cast<MessagePipeDispatcher*>(dispatcher1.get()); 750 static_cast<MessagePipeDispatcher*>(dispatcher1.get());
748 751
749 if (!mpd0->Fuse(mpd1)) 752 if (!mpd0->Fuse(mpd1))
750 return MOJO_RESULT_FAILED_PRECONDITION; 753 return MOJO_RESULT_FAILED_PRECONDITION;
751 754
752 return MOJO_RESULT_OK; 755 return MOJO_RESULT_OK;
753 } 756 }
754 757
758 MojoResult Core::NotifyBadMessage(MojoMessageHandle message,
759 const char* error,
760 size_t error_num_bytes) {
761 if (!message)
762 return MOJO_RESULT_INVALID_ARGUMENT;
763
764 const PortsMessage& ports_message =
765 reinterpret_cast<MessageForTransit*>(message)->ports_message();
766 if (ports_message.source_node() == ports::kInvalidNodeName) {
767 DVLOG(1) << "Received invalid message from unknown node.";
768 return MOJO_RESULT_OK;
769 }
770
771 GetNodeController()->NotifyBadMessageFrom(
772 ports_message.source_node(), std::string(error, error_num_bytes));
773 return MOJO_RESULT_OK;
774 }
775
755 MojoResult Core::CreateDataPipe( 776 MojoResult Core::CreateDataPipe(
756 const MojoCreateDataPipeOptions* options, 777 const MojoCreateDataPipeOptions* options,
757 MojoHandle* data_pipe_producer_handle, 778 MojoHandle* data_pipe_producer_handle,
758 MojoHandle* data_pipe_consumer_handle) { 779 MojoHandle* data_pipe_consumer_handle) {
759 RequestContext request_context; 780 RequestContext request_context;
760 if (options && options->struct_size != sizeof(MojoCreateDataPipeOptions)) 781 if (options && options->struct_size != sizeof(MojoCreateDataPipeOptions))
761 return MOJO_RESULT_INVALID_ARGUMENT; 782 return MOJO_RESULT_INVALID_ARGUMENT;
762 783
763 MojoCreateDataPipeOptions create_options; 784 MojoCreateDataPipeOptions create_options;
764 create_options.struct_size = sizeof(MojoCreateDataPipeOptions); 785 create_options.struct_size = sizeof(MojoCreateDataPipeOptions);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 std::unique_ptr<NodeController> node_controller) { 1165 std::unique_ptr<NodeController> node_controller) {
1145 // It's OK to leak this reference. At this point we know the IO loop is still 1166 // It's OK to leak this reference. At this point we know the IO loop is still
1146 // running, and we know the NodeController will observe its eventual 1167 // running, and we know the NodeController will observe its eventual
1147 // destruction. This tells the NodeController to delete itself when that 1168 // destruction. This tells the NodeController to delete itself when that
1148 // happens. 1169 // happens.
1149 node_controller.release()->DestroyOnIOThreadShutdown(); 1170 node_controller.release()->DestroyOnIOThreadShutdown();
1150 } 1171 }
1151 1172
1152 } // namespace edk 1173 } // namespace edk
1153 } // namespace mojo 1174 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/message_for_transit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698