Bug 1362388 - Remove nsAHttpTransaction::Available as footgun r=nwgh
☠☠ backed out by caa75fa65be6 ☠ ☠
authorPatrick McManus <mcmanus@ducksong.com>
Fri, 05 May 2017 18:12:36 -0400
changeset 405926 fef09999e00338ba3b6e54d97a9c0c8749e03dc2
parent 405925 a418e4a81c02e5c8a5d7f34b44d79df4a1a6d196
child 405927 0acdb2ad7e97dac72b4b2c096a1027de2dbc063e
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnwgh
bugs1362388
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1362388 - Remove nsAHttpTransaction::Available as footgun r=nwgh nsAHttpTransaction::Available() obtained a bytecount from the abstract transaction's input stream. If that stream was derived from a file:// it would create janky IO - so remove the interface. Http2Push maintains a non-inherited interface which is used to check the number of bytes it has internally buffered in memory. 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
@@ -4036,23 +4036,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
@@ -647,25 +647,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)
 {