Bug 1464917 - Add GetMaxPacketLifeTime and GetMaxRetransmits to DataChannel; r?drno draft
authorDan Minor <dminor@mozilla.com>
Fri, 01 Jun 2018 08:20:51 -0400
changeset 802884 706ec4e3b843
parent 802798 7d3f3515c8ec
child 802885 feef069a2b24
child 802961 39aa2763e440
push id111987
push userbmo:dminor@mozilla.com
push dateFri, 01 Jun 2018 16:10:05 +0000
reviewersdrno
bugs1464917
milestone62.0a1
Bug 1464917 - Add GetMaxPacketLifeTime and GetMaxRetransmits to DataChannel; r?drno MozReview-Commit-ID: BqukQygumpi
dom/base/nsDOMDataChannel.cpp
netwerk/sctp/datachannel/DataChannel.cpp
netwerk/sctp/datachannel/DataChannel.h
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -134,23 +134,23 @@ bool
 nsDOMDataChannel::Reliable() const
 {
   return mDataChannel->GetType() == mozilla::DataChannelConnection::RELIABLE;
 }
 
 mozilla::dom::Nullable<uint16_t>
 nsDOMDataChannel::GetMaxPacketLifeTime() const
 {
-  return mozilla::dom::Nullable<uint16_t>();
+  return mDataChannel->GetMaxPacketLifeTime();
 }
 
 mozilla::dom::Nullable<uint16_t>
 nsDOMDataChannel::GetMaxRetransmits() const
 {
-  return mozilla::dom::Nullable<uint16_t>();
+  return mDataChannel->GetMaxRetransmits();
 }
 
 bool
 nsDOMDataChannel::Ordered() const
 {
   return mDataChannel->GetOrdered();
 }
 
--- a/netwerk/sctp/datachannel/DataChannel.cpp
+++ b/netwerk/sctp/datachannel/DataChannel.cpp
@@ -3167,16 +3167,34 @@ DataChannel::SendBinaryStream(nsIInputSt
 {
   if (!EnsureValidStream(aRv)) {
     return;
   }
 
   SendErrnoToErrorResult(mConnection->SendBlob(mStream, aBlob), aRv);
 }
 
+dom::Nullable<uint16_t>
+DataChannel::GetMaxPacketLifeTime() const
+{
+  if (mPrPolicy == SCTP_PR_SCTP_TTL) {
+    return dom::Nullable<uint16_t>(mPrValue);
+  }
+  return dom::Nullable<uint16_t>();
+}
+
+dom::Nullable<uint16_t>
+DataChannel::GetMaxRetransmits() const
+{
+  if (mPrPolicy == SCTP_PR_SCTP_RTX) {
+    return dom::Nullable<uint16_t>(mPrValue);
+  }
+  return dom::Nullable<uint16_t>();
+}
+
 // May be called from another (i.e. Main) thread!
 void
 DataChannel::AppReady()
 {
   ENSURE_DATACONNECTION;
 
   MutexAutoLock lock(mConnection->mLock);
 
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -414,16 +414,20 @@ public:
   // Send a binary message (TypedArray)
   void SendBinaryMsg(const nsACString &aMsg, ErrorResult& aRv);
 
   // Send a binary blob
   void SendBinaryStream(nsIInputStream *aBlob, ErrorResult& aRv);
 
   uint16_t GetType() { return mPrPolicy; }
 
+  dom::Nullable<uint16_t> GetMaxPacketLifeTime() const;
+
+  dom::Nullable<uint16_t> GetMaxRetransmits() const;
+
   bool GetOrdered() { return !(mFlags & DATA_CHANNEL_FLAGS_OUT_OF_ORDER_ALLOWED); }
 
   // Amount of data buffered to send
   uint32_t GetBufferedAmount()
   {
     if (!mConnection) {
       return 0;
     }