Mojo: Delete OutgoingBrokerClientInvitation

This EDK type is replaced with OutgoingInvitation in the public API.
All remaining consumers of the EDK type are migrated to the public
API in this CL, and the EDK type is deleted.

Bug: 844763
Change-Id: Ifc7bc48253bb725e7ce5e23fbb64c03d7c1ff74f
Reviewed-on: https://chromium-review.googlesource.com/1073079
Commit-Queue: Ken Rockot <[email protected]>
Reviewed-by: Siddhartha S <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Jay Civelli <[email protected]>
Cr-Commit-Position: refs/heads/master@{#564180}
diff --git a/content/browser/child_process_launcher_helper.cc b/content/browser/child_process_launcher_helper.cc
index b9ad8d7e..68ae99e 100644
--- a/content/browser/child_process_launcher_helper.cc
+++ b/content/browser/child_process_launcher_helper.cc
@@ -16,7 +16,7 @@
 #include "content/public/browser/child_process_launcher_utils.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/sandboxed_process_launcher_delegate.h"
-#include "mojo/edk/embedder/platform_channel_pair.h"
+#include "mojo/public/cpp/platform/platform_channel.h"
 
 #if defined(OS_ANDROID)
 #include "content/browser/android/launcher_thread.h"
@@ -69,32 +69,27 @@
     std::unique_ptr<SandboxedProcessLauncherDelegate> delegate,
     const base::WeakPtr<ChildProcessLauncher>& child_process_launcher,
     bool terminate_on_shutdown,
-    std::unique_ptr<mojo::edk::OutgoingBrokerClientInvitation>
-        broker_client_invitation,
-    const mojo::edk::ProcessErrorCallback& process_error_callback)
+    mojo::OutgoingInvitation mojo_invitation,
+    const mojo::ProcessErrorCallback& process_error_callback)
     : child_process_id_(child_process_id),
       client_thread_id_(client_thread_id),
       command_line_(std::move(command_line)),
       delegate_(std::move(delegate)),
       child_process_launcher_(child_process_launcher),
       terminate_on_shutdown_(terminate_on_shutdown),
-      broker_client_invitation_(std::move(broker_client_invitation)),
+      mojo_invitation_(std::move(mojo_invitation)),
       process_error_callback_(process_error_callback) {}
 
-ChildProcessLauncherHelper::~ChildProcessLauncherHelper() {
-}
+ChildProcessLauncherHelper::~ChildProcessLauncherHelper() = default;
 
 void ChildProcessLauncherHelper::StartLaunchOnClientThread() {
   DCHECK_CURRENTLY_ON(client_thread_id_);
 
   BeforeLaunchOnClientThread();
 
-  mojo_server_handle_ = PrepareMojoPipeHandlesOnClientThread();
-  if (!mojo_server_handle_.is_valid()) {
-    mojo::edk::PlatformChannelPair channel_pair;
-    mojo_server_handle_ = channel_pair.PassServerHandle();
-    mojo_client_handle_ = channel_pair.PassClientHandle();
-  }
+  mojo_named_channel_ = CreateNamedPlatformChannelOnClientThread();
+  if (!mojo_named_channel_)
+    mojo_channel_.emplace();
 
   GetProcessLauncherTaskRunner()->PostTask(
       FROM_HERE,
@@ -130,10 +125,8 @@
 void ChildProcessLauncherHelper::PostLaunchOnLauncherThread(
     ChildProcessLauncherHelper::Process process,
     int launch_result) {
-  // Release the client handle now that the process has been started (the pipe
-  // may not signal when the process dies otherwise and we would not detect the
-  // child process died).
-  mojo_client_handle_.reset();
+  if (mojo_channel_)
+    mojo_channel_->RemoteProcessLaunched();
 
   if (process.process.IsValid()) {
     RecordHistogramsOnLauncherThread(base::TimeTicks::Now() -
@@ -142,16 +135,20 @@
 
   // Take ownership of the broker client invitation here so it's destroyed when
   // we go out of scope regardless of the outcome below.
-  std::unique_ptr<mojo::edk::OutgoingBrokerClientInvitation> invitation =
-      std::move(broker_client_invitation_);
+  mojo::OutgoingInvitation invitation = std::move(mojo_invitation_);
   if (process.process.IsValid()) {
     // Set up Mojo IPC to the new process.
-    DCHECK(invitation);
-    invitation->Send(
-        process.process.Handle(),
-        mojo::edk::ConnectionParams(mojo::edk::TransportProtocol::kLegacy,
-                                    std::move(mojo_server_handle_)),
-        process_error_callback_);
+    if (mojo_channel_) {
+      DCHECK(mojo_channel_->local_endpoint().is_valid());
+      mojo::OutgoingInvitation::Send(
+          std::move(invitation), process.process.Handle(),
+          mojo_channel_->TakeLocalEndpoint(), process_error_callback_);
+    } else {
+      DCHECK(mojo_named_channel_);
+      mojo::OutgoingInvitation::Send(
+          std::move(invitation), process.process.Handle(),
+          mojo_named_channel_->TakeServerEndpoint(), process_error_callback_);
+    }
   }
 
   BrowserThread::PostTask(