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

Unified Diff: ipc/ipc_channel_common.cc

Issue 2109213003: Add helper function to generate a pair of ChannelHandles for ChannelMojo. (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
« no previous file with comments | « ipc/ipc_channel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_common.cc
diff --git a/ipc/ipc_channel_common.cc b/ipc/ipc_channel_common.cc
index d7bbef6656726a5e6d242d190988bdcfd68ba75a..3002b6659853987aa1cc1e2702d949918d60324c 100644
--- a/ipc/ipc_channel_common.cc
+++ b/ipc/ipc_channel_common.cc
@@ -5,6 +5,7 @@
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_mojo.h"
+#include "mojo/public/cpp/system/message_pipe.h"
namespace IPC {
@@ -56,6 +57,30 @@ std::unique_ptr<Channel> Channel::CreateServer(
return Channel::Create(channel_handle, Channel::MODE_SERVER, listener);
}
+// static
+void Channel::GenerateMojoChannelHandlePair(
+ const std::string& name_postfix,
+ IPC::ChannelHandle* handle0,
+ IPC::ChannelHandle* handle1) {
+ DCHECK_NE(handle0, handle1);
+ // |name| is only used for logging and to aid developers in debugging. It
+ // doesn't _need_ to be unique, but this string is probably more useful than a
+ // generic "ChannelMojo".
+#if !defined(OS_NACL_SFI)
+ std::string name = "ChannelMojo-" + GenerateUniqueRandomChannelID();
+#else
+ std::string name = "ChannelMojo";
+#endif
+ if (!name_postfix.empty()) {
+ name += "-" + name_postfix;
+ }
+ mojo::MessagePipe message_pipe;
+ *handle0 = ChannelHandle(name);
+ handle0->mojo_handle = message_pipe.handle0.release();
+ *handle1 = ChannelHandle(name);
+ handle1->mojo_handle = message_pipe.handle1.release();
+}
+
Channel::~Channel() {
}
« no previous file with comments | « ipc/ipc_channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698