Delete AsyncSocketAdapter::Attach, make socket construction time const

Bug: webrtc:6424
Change-Id: I7001c4ac52ddd267dcd55f751f3f38976eab820f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227032
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34722}
diff --git a/rtc_base/openssl_adapter.cc b/rtc_base/openssl_adapter.cc
index 42195de..d6e1a60 100644
--- a/rtc_base/openssl_adapter.cc
+++ b/rtc_base/openssl_adapter.cc
@@ -271,7 +271,7 @@
 
   ssl_host_name_ = hostname;
 
-  if (socket_->GetState() != Socket::CS_CONNECTED) {
+  if (GetSocket()->GetState() != Socket::CS_CONNECTED) {
     state_ = SSL_WAIT;
     return 0;
   }
@@ -308,7 +308,7 @@
     return -1;
   }
 
-  std::unique_ptr<BIO, decltype(&::BIO_free)> bio{BIO_new_socket(socket_),
+  std::unique_ptr<BIO, decltype(&::BIO_free)> bio{BIO_new_socket(GetSocket()),
                                                   ::BIO_free};
   if (!bio) {
     return -1;
@@ -578,8 +578,8 @@
 int OpenSSLAdapter::SendTo(const void* pv,
                            size_t cb,
                            const SocketAddress& addr) {
-  if (socket_->GetState() == Socket::CS_CONNECTED &&
-      addr == socket_->GetRemoteAddress()) {
+  if (GetSocket()->GetState() == Socket::CS_CONNECTED &&
+      addr == GetSocket()->GetRemoteAddress()) {
     return Send(pv, cb);
   }
 
@@ -640,7 +640,7 @@
                              size_t cb,
                              SocketAddress* paddr,
                              int64_t* timestamp) {
-  if (socket_->GetState() == Socket::CS_CONNECTED) {
+  if (GetSocket()->GetState() == Socket::CS_CONNECTED) {
     int ret = Recv(pv, cb, timestamp);
     *paddr = GetRemoteAddress();
     return ret;
@@ -657,7 +657,7 @@
 }
 
 Socket::ConnState OpenSSLAdapter::GetState() const {
-  ConnState state = socket_->GetState();
+  ConnState state = GetSocket()->GetState();
   if ((state == CS_CONNECTED) &&
       ((state_ == SSL_WAIT) || (state_ == SSL_CONNECTING))) {
     state = CS_CONNECTING;