Bug 1362388 - Remove nsAHttpTransaction::Available as footgun draft
authorPatrick McManus <mcmanus@ducksong.com>
Fri, 05 May 2017 18:12:36 -0400
changeset 573654 3bda6737b01819e072feacb8d3318b7afd36f4d1
parent 573653 4e8067ee9fe45263385a94b825865557d22fb927
child 627355 84c6cf85531e2d846dea6eeb68af8cd8cacf98ec
push id57451
push userbmo:mcmanus@ducksong.com
push dateSat, 06 May 2017 01:20:56 +0000
bugs1362388
milestone55.0a1
Bug 1362388 - Remove nsAHttpTransaction::Available as footgun MozReview-Commit-ID: IQHt8yGsqDE
netwerk/protocol/http/Http2Push.h
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/NullHttpTransaction.cpp
netwerk/protocol/http/TunnelUtils.cpp
netwerk/protocol/http/nsAHttpTransaction.h
netwerk/protocol/http/nsHttpTransaction.cpp
--- a/netwerk/protocol/http/Http2Push.h
+++ b/netwerk/protocol/http/Http2Push.h
@@ -108,16 +108,17 @@ public:
   Http2PushTransactionBuffer();
 
   MOZ_MUST_USE nsresult GetBufferedData(char *buf, uint32_t count,
                                         uint32_t *countWritten);
   void SetPushStream(Http2PushedStream *stream) { mPushStream = stream; }
 
 private:
   virtual ~Http2PushTransactionBuffer();
+  uint64_t Available();
 
   const static uint32_t kDefaultBufferSize = 4096;
 
   nsresult mStatus;
   nsHttpRequestHead *mRequestHead;
   Http2PushedStream *mPushStream;
   bool mIsDone;
 
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -4038,23 +4038,16 @@ Http2Session::Caps()
 }
 
 void
 Http2Session::SetDNSWasRefreshed()
 {
   MOZ_ASSERT(false, "Http2Session::SetDNSWasRefreshed()");
 }
 
-uint64_t
-Http2Session::Available()
-{
-  MOZ_ASSERT(false, "Http2Session::Available()");
-  return 0;
-}
-
 nsHttpRequestHead *
 Http2Session::RequestHead()
 {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   MOZ_ASSERT(false,
              "Http2Session::RequestHead() "
              "should not be called after http/2 is setup");
   return NULL;
--- a/netwerk/protocol/http/NullHttpTransaction.cpp
+++ b/netwerk/protocol/http/NullHttpTransaction.cpp
@@ -203,22 +203,16 @@ NullHttpTransaction::Caps()
 
 void
 NullHttpTransaction::SetDNSWasRefreshed()
 {
   MOZ_ASSERT(NS_IsMainThread(), "SetDNSWasRefreshed on main thread only!");
   mCapsToClear |= NS_HTTP_REFRESH_DNS;
 }
 
-uint64_t
-NullHttpTransaction::Available()
-{
-  return 0;
-}
-
 nsresult
 NullHttpTransaction::ReadSegments(nsAHttpSegmentReader *reader,
                                   uint32_t count, uint32_t *countRead)
 {
   *countRead = 0;
   mIsDone = true;
   return NS_BASE_STREAM_CLOSED;
 }
--- a/netwerk/protocol/http/TunnelUtils.cpp
+++ b/netwerk/protocol/http/TunnelUtils.cpp
@@ -611,26 +611,16 @@ TLSFilterTransaction::SetDNSWasRefreshed
 {
   if (!mTransaction) {
     return;
   }
 
   mTransaction->SetDNSWasRefreshed();
 }
 
-uint64_t
-TLSFilterTransaction::Available()
-{
-  if (!mTransaction) {
-    return 0;
-  }
-
-  return mTransaction->Available();
-}
-
 void
 TLSFilterTransaction::SetProxyConnectFailed()
 {
   if (!mTransaction) {
     return;
   }
 
   mTransaction->SetProxyConnectFailed();
--- a/netwerk/protocol/http/nsAHttpTransaction.h
+++ b/netwerk/protocol/http/nsAHttpTransaction.h
@@ -59,19 +59,16 @@ public:
     // called to check the transaction status.
     virtual bool     IsDone() = 0;
     virtual nsresult Status() = 0;
     virtual uint32_t Caps() = 0;
 
     // called to notify that a requested DNS cache entry was refreshed.
     virtual void     SetDNSWasRefreshed() = 0;
 
-    // called to find out how much request data is available for writing.
-    virtual uint64_t Available() = 0;
-
     // called to read request data from the transaction.
     virtual MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *reader,
                                                uint32_t count,
                                                uint32_t *countRead) = 0;
 
     // called to write response data to the transaction.
     virtual MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *writer,
                                                 uint32_t count,
@@ -209,17 +206,16 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAHttpTra
     nsAHttpConnection *Connection() override; \
     void GetSecurityCallbacks(nsIInterfaceRequestor **) override;       \
     void OnTransportStatus(nsITransport* transport, \
                            nsresult status, int64_t progress) override; \
     bool     IsDone() override; \
     nsresult Status() override; \
     uint32_t Caps() override;   \
     void     SetDNSWasRefreshed() override; \
-    uint64_t Available() override; \
     virtual MOZ_MUST_USE nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *) override; \
     virtual MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *) override; \
     virtual void Close(nsresult reason) override;                                \
     nsHttpConnectionInfo *ConnectionInfo() override;                             \
     void     SetProxyConnectFailed() override;                                   \
     virtual nsHttpRequestHead *RequestHead() override;                                   \
     uint32_t Http1xTransactionCount() override;                                  \
     MOZ_MUST_USE nsresult TakeSubTransactions(nsTArray<RefPtr<nsAHttpTransaction> > &outTransactions) override;
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -649,25 +649,16 @@ nsHttpTransaction::Caps()
 
 void
 nsHttpTransaction::SetDNSWasRefreshed()
 {
     MOZ_ASSERT(NS_IsMainThread(), "SetDNSWasRefreshed on main thread only!");
     mCapsToClear |= NS_HTTP_REFRESH_DNS;
 }
 
-uint64_t
-nsHttpTransaction::Available()
-{
-    uint64_t size;
-    if (NS_FAILED(mRequestStream->Available(&size)))
-        size = 0;
-    return size;
-}
-
 nsresult
 nsHttpTransaction::ReadRequestSegment(nsIInputStream *stream,
                                       void *closure,
                                       const char *buf,
                                       uint32_t offset,
                                       uint32_t count,
                                       uint32_t *countRead)
 {