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

Unified Diff: content/common/child_process_host_impl.cc

Issue 1959313002: Use ChannelMojo for the utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-all-processes
Patch Set: rebase 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 | « content/common/child_process_host_impl.h ('k') | content/public/common/child_process_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/child_process_host_impl.cc
diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc
index 1aa93b529873b9e7d342ad3e3f955ac36638385f..909a3d6ee256f974a39ac1416e44acd43c121698 100644
--- a/content/common/child_process_host_impl.cc
+++ b/content/common/child_process_host_impl.cc
@@ -31,6 +31,8 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_logging.h"
#include "ipc/message_filter.h"
+#include "ipc/mojo/ipc_channel_mojo.h"
+#include "mojo/edk/embedder/embedder.h"
#if defined(OS_LINUX)
#include "base/linux_util.h"
@@ -130,9 +132,31 @@ void ChildProcessHostImpl::ForceShutdown() {
Send(new ChildProcessMsg_Shutdown());
}
+std::string ChildProcessHostImpl::CreateChannelMojo(
+ const std::string& child_token) {
+ DCHECK(channel_id_.empty());
+ channel_id_ = mojo::edk::GenerateRandomToken();
+ mojo::ScopedMessagePipeHandle host_handle =
+ mojo::edk::CreateParentMessagePipe(channel_id_, child_token);
+ channel_ = IPC::ChannelMojo::Create(std::move(host_handle),
+ IPC::Channel::MODE_SERVER, this);
+ if (!channel_ || !InitChannel())
+ return std::string();
+
+ return channel_id_;
+}
+
std::string ChildProcessHostImpl::CreateChannel() {
+ DCHECK(channel_id_.empty());
channel_id_ = IPC::Channel::GenerateVerifiedChannelID(std::string());
channel_ = IPC::Channel::CreateServer(channel_id_, this);
+ if (!channel_ || !InitChannel())
+ return std::string();
+
+ return channel_id_;
+}
+
+bool ChildProcessHostImpl::InitChannel() {
#if USE_ATTACHMENT_BROKER
IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
channel_.get(), base::MessageLoopForIO::current()->task_runner());
@@ -142,7 +166,7 @@ std::string ChildProcessHostImpl::CreateChannel() {
IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
channel_.get());
#endif
- return std::string();
+ return false;
}
for (size_t i = 0; i < filters_.size(); ++i)
@@ -156,7 +180,7 @@ std::string ChildProcessHostImpl::CreateChannel() {
opening_channel_ = true;
- return channel_id_;
+ return true;
}
bool ChildProcessHostImpl::IsChannelOpening() {
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/public/common/child_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698