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

Unified Diff: mojo/edk/system/node_channel.h

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/node_channel.h
diff --git a/mojo/edk/system/node_channel.h b/mojo/edk/system/node_channel.h
index 1aeccda10aa5f1123fdfb6d81a33a6d191159bc4..5fb0b9f786939c5c3ac343a75f75b6eebd61ee6f 100644
--- a/mojo/edk/system/node_channel.h
+++ b/mojo/edk/system/node_channel.h
@@ -9,6 +9,7 @@
#include <unordered_map>
#include <utility>
+#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/process/process_handle.h"
@@ -68,6 +69,9 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
base::ProcessHandle from_process,
const ports::NodeName& destination,
Channel::MessagePtr message) = 0;
+ virtual void OnPortsMessageFromRelay(const ports::NodeName& from_node,
+ const ports::NodeName& source_node,
+ Channel::MessagePtr message) = 0;
#endif
virtual void OnChannelError(const ports::NodeName& node) = 0;
@@ -80,7 +84,8 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
static scoped_refptr<NodeChannel> Create(
Delegate* delegate,
ScopedPlatformHandle platform_handle,
- scoped_refptr<base::TaskRunner> io_task_runner);
+ scoped_refptr<base::TaskRunner> io_task_runner,
+ const base::Closure& bad_message_callback);
static Channel::MessagePtr CreatePortsMessage(size_t payload_size,
void** payload,
@@ -95,6 +100,9 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
// Permanently stop the channel from sending or receiving messages.
void ShutDown();
+ // Invokes the bad message callback for this channel, if any.
+ void NotifyBadMessage();
+
void SetRemoteProcessHandle(base::ProcessHandle process_handle);
bool HasRemoteProcessHandle();
// Note: The returned |ProcessHandle| is owned by the caller and should be
@@ -128,6 +136,12 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
// assumed to have that permission.
void RelayPortsMessage(const ports::NodeName& destination,
Channel::MessagePtr message);
+
+ // Sends a message to its destination from a relay. This is interpreted by the
+ // receiver similarly to PortsMessage, but the original source node is
+ // provided as additional message metadata from the (trusted) relay node.
+ void PortsMessageFromRelay(const ports::NodeName& source,
+ Channel::MessagePtr message);
#endif
private:
@@ -139,7 +153,8 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
NodeChannel(Delegate* delegate,
ScopedPlatformHandle platform_handle,
- scoped_refptr<base::TaskRunner> io_task_runner);
+ scoped_refptr<base::TaskRunner> io_task_runner,
+ const base::Closure& bad_message_callback);
~NodeChannel() override;
// Channel::Delegate:
@@ -159,6 +174,7 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
Delegate* const delegate_;
const scoped_refptr<base::TaskRunner> io_task_runner_;
+ const base::Closure bad_message_callback_;
base::Lock channel_lock_;
scoped_refptr<Channel> channel_;

Powered by Google App Engine
This is Rietveld 408576698