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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: mojo/edk/system/core.cc
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index ef10e9c29d1465d18985ca84fc9210002cbf51fe..f7e1521e6b2669d8dd6cbc37f762a40521122017 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -30,6 +30,7 @@
#include "mojo/edk/system/message_for_transit.h"
#include "mojo/edk/system/message_pipe_dispatcher.h"
#include "mojo/edk/system/platform_handle_dispatcher.h"
+#include "mojo/edk/system/ports/name.h"
#include "mojo/edk/system/ports/node.h"
#include "mojo/edk/system/remote_message_pipe_bootstrap.h"
#include "mojo/edk/system/request_context.h"
@@ -169,10 +170,12 @@ scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) {
void Core::AddChild(base::ProcessHandle process_handle,
ScopedPlatformHandle platform_handle,
- const std::string& child_token) {
+ const std::string& child_token,
+ const base::Closure& bad_message_callback) {
GetNodeController()->ConnectToChild(process_handle,
std::move(platform_handle),
- child_token);
+ child_token,
+ bad_message_callback);
}
void Core::ChildLaunchFailed(const std::string& child_token) {
@@ -752,6 +755,21 @@ MojoResult Core::FuseMessagePipes(MojoHandle handle0, MojoHandle handle1) {
return MOJO_RESULT_OK;
}
+MojoResult Core::NotifyBadMessage(MojoMessageHandle message) {
+ if (!message)
+ return MOJO_RESULT_INVALID_ARGUMENT;
+
+ const PortsMessage& ports_message =
+ reinterpret_cast<MessageForTransit*>(message)->ports_message();
+ if (ports_message.source_node() == ports::kInvalidNodeName) {
+ DVLOG(1) << "Received invalid message from unknown node.";
+ return MOJO_RESULT_OK;
+ }
+
+ GetNodeController()->NotifyBadMessageFrom(ports_message.source_node());
+ return MOJO_RESULT_OK;
+}
+
MojoResult Core::CreateDataPipe(
const MojoCreateDataPipeOptions* options,
MojoHandle* data_pipe_producer_handle,

Powered by Google App Engine
This is Rietveld 408576698