Mojo EDK: Require explicit TransportProtocol in ConnectionParams ctor

This removes the ConnectionParams constructor which implies
TransportProtocol::kLegacy and updates all callers to specify the
protocl explicitly.

No functional change, so TBRing.

BUG=696031
TBR=jam@chromium.org
TBR=jcivelli@chromium.org

Change-Id: Ifb02e7b49eabefa94b1cf29388ea728dd5962177
Reviewed-on: https://chromium-review.googlesource.com/503610
Reviewed-by: Ken Rockot <rockot@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#471145}

CrOS-Libchrome-Original-Commit: 29bd77bcacd88ec3d568905098484c83c988d4fd
diff --git a/mojo/edk/embedder/README.md b/mojo/edk/embedder/README.md
index e490daf..0b4a30a 100644
--- a/mojo/edk/embedder/README.md
+++ b/mojo/edk/embedder/README.md
@@ -230,8 +230,10 @@
 
   base::ProcessHandle child_handle =
       LaunchCoolChildProcess(channel.PassClientHandle());
-  invitation.Send(child_handle,
-                  mojo::edk::ConnectionParams(channel.PassServerHandle()));
+  invitation.Send(
+      child_handle,
+      mojo::edk::ConnectionParams(mojo::edk::TransportProtocol::kLegacy,
+                                  channel.PassServerHandle()));
 
   // We can start using our end of the pipe immediately. Here we assume the
   // other end will eventually be bound to a local::mojom::Foo implementation,
@@ -290,7 +292,8 @@
       mojo::edk::ScopedIPCSupport::ShutdownPolicy::CLEAN);
 
   auto invitation = mojo::edk::IncomingBrokerClientInvitation::Accept(
-      mojo::edk::ConnectionParams(GetChannelHandle()));
+      mojo::edk::ConnectionParams(mojo::edk::TransportProtocol::kLegacy,
+                                  GetChannelHandle()));
 
   mojo::ScopedMessagePipeHandle my_pipe =
       invitation->ExtractMessagePipe("pretty_cool_pipe");
diff --git a/mojo/edk/embedder/connection_params.cc b/mojo/edk/embedder/connection_params.cc
index 92c343c..6d7c41a 100644
--- a/mojo/edk/embedder/connection_params.cc
+++ b/mojo/edk/embedder/connection_params.cc
@@ -11,9 +11,6 @@
 namespace mojo {
 namespace edk {
 
-ConnectionParams::ConnectionParams(ScopedPlatformHandle channel)
-    : ConnectionParams(TransportProtocol::kLegacy, std::move(channel)) {}
-
 ConnectionParams::ConnectionParams(TransportProtocol protocol,
                                    ScopedPlatformHandle channel)
     : protocol_(protocol), channel_(std::move(channel)) {
@@ -25,11 +22,8 @@
   *this = std::move(params);
 }
 
-ConnectionParams& ConnectionParams::operator=(ConnectionParams&& params) {
-  protocol_ = params.protocol_;
-  channel_ = std::move(params.channel_);
-  return *this;
-}
+ConnectionParams& ConnectionParams::operator=(ConnectionParams&& params) =
+    default;
 
 ScopedPlatformHandle ConnectionParams::TakeChannelHandle() {
   return std::move(channel_);
diff --git a/mojo/edk/embedder/connection_params.h b/mojo/edk/embedder/connection_params.h
index c85bb02..2e8a711 100644
--- a/mojo/edk/embedder/connection_params.h
+++ b/mojo/edk/embedder/connection_params.h
@@ -17,10 +17,6 @@
 // A set of parameters used when establishing a connection to another process.
 class MOJO_SYSTEM_IMPL_EXPORT ConnectionParams {
  public:
-  // Configures an OS pipe-based, |kBrokerClient| connection to the remote
-  // process using the legacy transport protocol.
-  explicit ConnectionParams(ScopedPlatformHandle channel);
-
   // Configures an OS pipe-based connection of type |type| to the remote process
   // using the given transport |protocol|.
   ConnectionParams(TransportProtocol protocol, ScopedPlatformHandle channel);
diff --git a/mojo/edk/embedder/embedder_unittest.cc b/mojo/edk/embedder/embedder_unittest.cc
index 7e60397..a59e041 100644
--- a/mojo/edk/embedder/embedder_unittest.cc
+++ b/mojo/edk/embedder/embedder_unittest.cc
@@ -145,8 +145,9 @@
 
   OutgoingBrokerClientInvitation invitation;
   ScopedMessagePipeHandle parent_mp = invitation.AttachMessagePipe("unused");
-  invitation.Send(base::GetCurrentProcessHandle(),
-                  ConnectionParams(pair.PassServerHandle()));
+  invitation.Send(
+      base::GetCurrentProcessHandle(),
+      ConnectionParams(TransportProtocol::kLegacy, pair.PassServerHandle()));
 
   // Close the remote end, simulating child death before the child extracts the
   // attached message pipe.
diff --git a/mojo/edk/system/broker_host.cc b/mojo/edk/system/broker_host.cc
index 6096034..751495b 100644
--- a/mojo/edk/system/broker_host.cc
+++ b/mojo/edk/system/broker_host.cc
@@ -29,8 +29,10 @@
 
   base::MessageLoop::current()->AddDestructionObserver(this);
 
-  channel_ = Channel::Create(this, ConnectionParams(std::move(platform_handle)),
-                             base::ThreadTaskRunnerHandle::Get());
+  channel_ = Channel::Create(
+      this,
+      ConnectionParams(TransportProtocol::kLegacy, std::move(platform_handle)),
+      base::ThreadTaskRunnerHandle::Get());
   channel_->Start();
 }
 
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index 3c08980..1d90197 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -200,7 +200,8 @@
   GetNodeController()->node()->CreatePortPair(&port0, &port1);
   MojoHandle handle = AddDispatcher(new MessagePipeDispatcher(
       GetNodeController(), port0, kUnknownPipeIdForDebug, 0));
-  ConnectionParams connection_params(std::move(pipe_handle));
+  ConnectionParams connection_params(TransportProtocol::kLegacy,
+                                     std::move(pipe_handle));
   GetNodeController()->ConnectToPeer(std::move(connection_params), port1,
                                      peer_token);
   return ScopedMessagePipeHandle(MessagePipeHandle(handle));
diff --git a/mojo/edk/system/node_controller.cc b/mojo/edk/system/node_controller.cc
index e47725a..0901022 100644
--- a/mojo/edk/system/node_controller.cc
+++ b/mojo/edk/system/node_controller.cc
@@ -229,7 +229,8 @@
     CancelPendingPortMerges();
     return;
   }
-  connection_params = ConnectionParams(std::move(platform_handle));
+  connection_params = ConnectionParams(connection_params.protocol(),
+                                       std::move(platform_handle));
 #endif
 
   io_task_runner_->PostTask(
@@ -363,9 +364,10 @@
   CHECK(channel_ok);
 #endif  // defined(OS_WIN)
 
-  scoped_refptr<NodeChannel> channel =
-      NodeChannel::Create(this, ConnectionParams(std::move(server_handle)),
-                          io_task_runner_, process_error_callback);
+  scoped_refptr<NodeChannel> channel = NodeChannel::Create(
+      this,
+      ConnectionParams(connection_params.protocol(), std::move(server_handle)),
+      io_task_runner_, process_error_callback);
 
 #else  // !defined(OS_MACOSX) && !defined(OS_NACL)
   scoped_refptr<NodeChannel> channel =
@@ -940,7 +942,8 @@
   }
 
   PlatformChannelPair broker_channel;
-  ConnectionParams connection_params(broker_channel.PassServerHandle());
+  ConnectionParams connection_params(TransportProtocol::kLegacy,
+                                     broker_channel.PassServerHandle());
   scoped_refptr<NodeChannel> client =
       NodeChannel::Create(this, std::move(connection_params), io_task_runner_,
                           ProcessErrorCallback());
@@ -1021,9 +1024,10 @@
     broker = parent;
   } else {
     DCHECK(broker_channel.is_valid());
-    broker =
-        NodeChannel::Create(this, ConnectionParams(std::move(broker_channel)),
-                            io_task_runner_, ProcessErrorCallback());
+    broker = NodeChannel::Create(
+        this,
+        ConnectionParams(TransportProtocol::kLegacy, std::move(broker_channel)),
+        io_task_runner_, ProcessErrorCallback());
     AddPeer(broker_name, broker, true /* start_channel */);
   }
 
@@ -1161,9 +1165,10 @@
     return;
   }
 
-  scoped_refptr<NodeChannel> channel =
-      NodeChannel::Create(this, ConnectionParams(std::move(channel_handle)),
-                          io_task_runner_, ProcessErrorCallback());
+  scoped_refptr<NodeChannel> channel = NodeChannel::Create(
+      this,
+      ConnectionParams(TransportProtocol::kLegacy, std::move(channel_handle)),
+      io_task_runner_, ProcessErrorCallback());
 
   DVLOG(1) << "Adding new peer " << name << " via parent introduction.";
   AddPeer(name, channel, true /* start_channel */);