Backed out 2 changesets (bug 1435899) for failing android at modules/libpref/test/unit/test_defaultValues.js pn a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Fri, 09 Mar 2018 23:14:32 +0200
changeset 765601 09ecb6d589490df1abb869bf025ce094ba87bcac
parent 765600 ac6bc78dadb9d7fb66d8c8b67d65948e1ed64b9a
child 765602 844f09651ee1477c6dab0328bd80745043d76953
child 765653 40063d96ba8eb7efa2051759576ed1d1ac62f55b
push id102114
push userbmo:jgilbert@mozilla.com
push dateFri, 09 Mar 2018 22:13:16 +0000
bugs1435899
milestone60.0a1
backs out925adb267211585b0cfd2f6b4e219857ecca7921
f22f1ab67c5ace0d966a3f60f7b1e25dfe4ec6c9
Backed out 2 changesets (bug 1435899) for failing android at modules/libpref/test/unit/test_defaultValues.js pn a CLOSED TREE Backed out changeset 925adb267211 (bug 1435899) Backed out changeset f22f1ab67c5a (bug 1435899)
netwerk/protocol/data/nsDataChannel.cpp
xpcom/io/NonBlockingAsyncInputStream.cpp
--- a/netwerk/protocol/data/nsDataChannel.cpp
+++ b/netwerk/protocol/data/nsDataChannel.cpp
@@ -3,20 +3,22 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // data implementation
 
 #include "nsDataChannel.h"
 
 #include "mozilla/Base64.h"
+#include "nsIOService.h"
 #include "nsDataHandler.h"
+#include "nsIPipe.h"
 #include "nsIInputStream.h"
+#include "nsIOutputStream.h"
 #include "nsEscape.h"
-#include "nsStringStream.h"
 
 using namespace mozilla;
 
 /**
  * Helper for performing a fallible unescape.
  *
  * @param aStr The string to unescape.
  * @param aBuffer Buffer to unescape into if necessary.
@@ -79,28 +81,36 @@ nsDataChannel::OpenContentStream(bool as
         // Don't allow spaces in base64-encoded content. This is only
         // relevant for escaped spaces; other spaces are stripped in
         // NewURI. We know there were no escaped spaces if the data buffer
         // wasn't used in |Unescape|.
         unescapedBuffer.StripWhitespace();
     }
 
     nsCOMPtr<nsIInputStream> bufInStream;
+    nsCOMPtr<nsIOutputStream> bufOutStream;
+
+    // create an unbounded pipe.
+    rv = NS_NewPipe(getter_AddRefs(bufInStream),
+                    getter_AddRefs(bufOutStream),
+                    nsIOService::gDefaultSegmentSize,
+                    UINT32_MAX,
+                    async, true);
+    if (NS_FAILED(rv))
+        return rv;
 
     uint32_t contentLen;
     if (lBase64) {
         nsAutoCString decodedData;
         rv = Base64Decode(data, decodedData);
         NS_ENSURE_SUCCESS(rv, rv);
 
-        contentLen = decodedData.Length();
-        rv = NS_NewCStringInputStream(getter_AddRefs(bufInStream), decodedData);
+        rv = bufOutStream->Write(decodedData.get(), decodedData.Length(), &contentLen);
     } else {
-        contentLen = data.Length();
-        rv = NS_NewCStringInputStream(getter_AddRefs(bufInStream), data);
+        rv = bufOutStream->Write(data.Data(), data.Length(), &contentLen);
     }
 
     if (NS_FAILED(rv))
         return rv;
 
     SetContentType(contentType);
     SetContentCharset(contentCharset);
     mContentLength = contentLen;
--- a/xpcom/io/NonBlockingAsyncInputStream.cpp
+++ b/xpcom/io/NonBlockingAsyncInputStream.cpp
@@ -164,29 +164,17 @@ NonBlockingAsyncInputStream::Close()
   return NS_OK;
 }
 
 // nsIInputStream interface
 
 NS_IMETHODIMP
 NonBlockingAsyncInputStream::Available(uint64_t* aLength)
 {
-  nsresult rv = mInputStream->Available(aLength);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  // Nothing more to read. Let's close the stream now.
-  if (*aLength == 0) {
-    mInputStream->Close();
-    mClosed = true;
-    return NS_BASE_STREAM_CLOSED;
-  }
-
-  return NS_OK;
+  return mInputStream->Available(aLength);
 }
 
 NS_IMETHODIMP
 NonBlockingAsyncInputStream::Read(char* aBuffer, uint32_t aCount,
                                   uint32_t* aReadCount)
 {
   return mInputStream->Read(aBuffer, aCount, aReadCount);
 }