Make sure channel-associated interface pointers are always safe to call.

Previously, GetRemoteAssociatedInterface() could drop the associated request if
the channel was not connected. It would lead to crash when the corresponding
associated interface pointer is used to make calls.

This CL makes the request associated with a dedicated, disconnected message pipe
instead of dropping it. That way it is safe to make calls with the interface
pointer.

BUG=704504

Review-Url: https://codereview.chromium.org/2772983002
Cr-Commit-Position: refs/heads/master@{#459642}
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc
index d0129e3..ab376f4b 100644
--- a/ipc/ipc_channel_mojo.cc
+++ b/ipc/ipc_channel_mojo.cc
@@ -479,8 +479,14 @@
 void ChannelMojo::GetGenericRemoteAssociatedInterface(
     const std::string& name,
     mojo::ScopedInterfaceEndpointHandle handle) {
-  if (message_reader_)
+  if (message_reader_) {
     message_reader_->GetRemoteInterface(name, std::move(handle));
+  } else {
+    // Attach the associated interface to a disconnected pipe, so that the
+    // associated interface pointer can be used to make calls (which are
+    // dropped).
+    mojo::GetIsolatedInterface(std::move(handle));
+  }
 }
 
 }  // namespace IPC