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

Unified Diff: components/arc/arc_session.cc

Issue 2680973006: Mojo EDK: Add safe process connection API (Closed)
Patch Set: . Created 3 years, 10 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: components/arc/arc_session.cc
diff --git a/components/arc/arc_session.cc b/components/arc/arc_session.cc
index 92940393eee96fd97454ed176ea02dcef86c0bd8..c063a64574273278a690b13e2d8c49e40426f0a0 100644
--- a/components/arc/arc_session.cc
+++ b/components/arc/arc_session.cc
@@ -33,6 +33,7 @@
#include "mojo/edk/embedder/embedder.h"
#include "mojo/edk/embedder/named_platform_handle.h"
#include "mojo/edk/embedder/named_platform_handle_utils.h"
+#include "mojo/edk/embedder/pending_process_connection.h"
#include "mojo/edk/embedder/platform_channel_pair.h"
#include "mojo/edk/embedder/platform_channel_utils_posix.h"
#include "mojo/edk/embedder/platform_handle_vector.h"
@@ -441,15 +442,16 @@ mojo::ScopedMessagePipeHandle ArcSessionImpl::ConnectMojo(
// Hardcode pid 0 since it is unused in mojo.
const base::ProcessHandle kUnusedChildProcessHandle = 0;
mojo::edk::PlatformChannelPair channel_pair;
- std::string child_token = mojo::edk::GenerateRandomToken();
- mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle,
- channel_pair.PassServerHandle(), child_token);
+ mojo::edk::PendingProcessConnection process;
+ process.Connect(kUnusedChildProcessHandle, channel_pair.PassServerHandle());
mojo::edk::ScopedPlatformHandleVectorPtr handles(
new mojo::edk::PlatformHandleVector{
channel_pair.PassClientHandle().release()});
- std::string token = mojo::edk::GenerateRandomToken();
+ std::string token;
+ mojo::ScopedMessagePipeHandle pipe = process.CreateMessagePipe(&token);
+
// We need to send the length of the message as a single byte, so make sure it
// fits.
DCHECK_LT(token.size(), 256u);
@@ -464,7 +466,7 @@ mojo::ScopedMessagePipeHandle ArcSessionImpl::ConnectMojo(
return mojo::ScopedMessagePipeHandle();
}
- return mojo::edk::CreateParentMessagePipe(token, child_token);
+ return pipe;
}
void ArcSessionImpl::OnMojoConnected(
« no previous file with comments | « chrome/utility/importer/firefox_importer_unittest_utils_mac.cc ('k') | components/nacl/broker/nacl_broker_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698