DtlsTransport::ice_transport is const and can be called off thread

Since the ice_transport element of DtlsTransport is never changed
over the lifetime of the object, it's safe to return it on any thread.
Added const qualifier to make this obvious.

Bug: chromium:907849
Change-Id: Ib180682689a57df5106717b125c626d7ac9e7561
Reviewed-on: https://webrtc-review.googlesource.com/c/123781
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26800}
diff --git a/pc/dtls_transport.cc b/pc/dtls_transport.cc
index 66e2787..38cef1e 100644
--- a/pc/dtls_transport.cc
+++ b/pc/dtls_transport.cc
@@ -45,12 +45,12 @@
     std::unique_ptr<cricket::DtlsTransportInternal> internal)
     : owner_thread_(rtc::Thread::Current()),
       info_(DtlsTransportState::kNew),
-      internal_dtls_transport_(std::move(internal)) {
+      internal_dtls_transport_(std::move(internal)),
+      ice_transport_(new rtc::RefCountedObject<IceTransportWithPointer>(
+          internal_dtls_transport_->ice_transport())) {
   RTC_DCHECK(internal_dtls_transport_.get());
   internal_dtls_transport_->SignalDtlsState.connect(
       this, &DtlsTransport::OnInternalDtlsState);
-  ice_transport_ = new rtc::RefCountedObject<IceTransportWithPointer>(
-      internal_dtls_transport_->ice_transport());
   UpdateInformation();
 }
 
@@ -77,8 +77,6 @@
 }
 
 rtc::scoped_refptr<IceTransportInterface> DtlsTransport::ice_transport() {
-  RTC_DCHECK_RUN_ON(owner_thread_);
-  rtc::CritScope scope(&lock_);
   return ice_transport_;
 }
 
diff --git a/pc/dtls_transport.h b/pc/dtls_transport.h
index 0251716..392532a 100644
--- a/pc/dtls_transport.h
+++ b/pc/dtls_transport.h
@@ -66,8 +66,7 @@
   DtlsTransportInformation info_ RTC_GUARDED_BY(lock_);
   std::unique_ptr<cricket::DtlsTransportInternal> internal_dtls_transport_
       RTC_GUARDED_BY(lock_);
-  rtc::scoped_refptr<IceTransportWithPointer> ice_transport_
-      RTC_GUARDED_BY(lock_);
+  const rtc::scoped_refptr<IceTransportWithPointer> ice_transport_;
 };
 
 }  // namespace webrtc