Bug 1223808 - part 3 - replace nsAutoArrayPtr<T> with UniquePtr<T[]> in netwerk/; r=mcmanus
authorNathan Froyd <froydnj@mozilla.com>
Sun, 08 Nov 2015 21:28:05 -0500
changeset 309480 cc847f227d9a2736a62ec10b3c2dc147b69c6d34
parent 309479 37997f6e43494a557ade83c7713ea59f78b65087
child 309481 10fb062fb1ae906a0ad43555ee0f62dfe7ec667f
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1223808
milestone45.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 1223808 - part 3 - replace nsAutoArrayPtr<T> with UniquePtr<T[]> in netwerk/; r=mcmanus
netwerk/base/nsIncrementalDownload.cpp
netwerk/protocol/http/Http2Push.cpp
netwerk/protocol/http/Http2Push.h
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/Http2Session.h
netwerk/protocol/http/Http2Stream.cpp
netwerk/protocol/http/Http2Stream.h
netwerk/protocol/http/SpdyPush31.cpp
netwerk/protocol/http/SpdyPush31.h
netwerk/protocol/http/SpdySession31.cpp
netwerk/protocol/http/SpdySession31.h
netwerk/protocol/http/SpdyStream31.cpp
netwerk/protocol/http/SpdyStream31.h
netwerk/protocol/http/TunnelUtils.cpp
netwerk/protocol/http/TunnelUtils.h
netwerk/protocol/http/nsHttp.cpp
netwerk/protocol/http/nsHttp.h
netwerk/streamconv/converters/nsFTPDirListingConv.cpp
netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
--- a/netwerk/base/nsIncrementalDownload.cpp
+++ b/netwerk/base/nsIncrementalDownload.cpp
@@ -1,31 +1,31 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #include "mozilla/Attributes.h"
+#include "mozilla/UniquePtrExtensions.h"
 
 #include "nsIIncrementalDownload.h"
 #include "nsIRequestObserver.h"
 #include "nsIProgressEventSink.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIObserverService.h"
 #include "nsIObserver.h"
 #include "nsIStreamListener.h"
 #include "nsIFile.h"
 #include "nsITimer.h"
 #include "nsIURI.h"
 #include "nsIInputStream.h"
 #include "nsNetUtil.h"
-#include "nsAutoPtr.h"
 #include "nsWeakReference.h"
 #include "prio.h"
 #include "prprf.h"
 #include <algorithm>
 #include "nsIContentPolicy.h"
 #include "nsContentUtils.h"
 
 // Default values used to initialize a nsIncrementalDownload object.
@@ -142,17 +142,17 @@ private:
   nsCOMPtr<nsIRequestObserver>             mObserver;
   nsCOMPtr<nsISupports>                    mObserverContext;
   nsCOMPtr<nsIProgressEventSink>           mProgressSink;
   nsCOMPtr<nsIURI>                         mURI;
   nsCOMPtr<nsIURI>                         mFinalURI;
   nsCOMPtr<nsIFile>                        mDest;
   nsCOMPtr<nsIChannel>                     mChannel;
   nsCOMPtr<nsITimer>                       mTimer;
-  nsAutoArrayPtr<char>                     mChunk;
+  UniquePtr<char[]>                        mChunk;
   int32_t                                  mChunkLen;
   int32_t                                  mChunkSize;
   int32_t                                  mInterval;
   int64_t                                  mTotalSize;
   int64_t                                  mCurrentSize;
   uint32_t                                 mLoadFlags;
   int32_t                                  mNonPartialCount;
   nsresult                                 mStatus;
@@ -186,17 +186,17 @@ nsIncrementalDownload::nsIncrementalDown
 nsresult
 nsIncrementalDownload::FlushChunk()
 {
   NS_ASSERTION(mTotalSize != int64_t(-1), "total size should be known");
 
   if (mChunkLen == 0)
     return NS_OK;
 
-  nsresult rv = AppendToFile(mDest, mChunk, mChunkLen);
+  nsresult rv = AppendToFile(mDest, mChunk.get(), mChunkLen);
   if (NS_FAILED(rv))
     return rv;
 
   mCurrentSize += int64_t(mChunkLen);
   mChunkLen = 0;
 
   return NS_OK;
 }
@@ -704,17 +704,17 @@ nsIncrementalDownload::OnStartRequest(ns
   if (diff <= int64_t(0)) {
     NS_WARNING("about to set a bogus chunk size; giving up");
     return NS_ERROR_UNEXPECTED;
   }
 
   if (diff < int64_t(mChunkSize))
     mChunkSize = uint32_t(diff);
 
-  mChunk = new char[mChunkSize];
+  mChunk = MakeUniqueFallible<char[]>(mChunkSize);
   if (!mChunk)
     rv = NS_ERROR_OUT_OF_MEMORY;
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsIncrementalDownload::OnStopRequest(nsIRequest *request,
@@ -761,17 +761,17 @@ nsIncrementalDownload::OnDataAvailable(n
                                        nsIInputStream *input,
                                        uint64_t offset,
                                        uint32_t count)
 {
   while (count) {
     uint32_t space = mChunkSize - mChunkLen;
     uint32_t n, len = std::min(space, count);
 
-    nsresult rv = input->Read(mChunk + mChunkLen, len, &n);
+    nsresult rv = input->Read(&mChunk[mChunkLen], len, &n);
     if (NS_FAILED(rv))
       return rv;
     if (n != len)
       return NS_ERROR_UNEXPECTED;
 
     count -= n;
     mChunkLen += n;
 
--- a/netwerk/protocol/http/Http2Push.cpp
+++ b/netwerk/protocol/http/Http2Push.cpp
@@ -249,17 +249,17 @@ Http2PushTransactionBuffer::Http2PushTra
   : mStatus(NS_OK)
   , mRequestHead(nullptr)
   , mPushStream(nullptr)
   , mIsDone(false)
   , mBufferedHTTP1Size(kDefaultBufferSize)
   , mBufferedHTTP1Used(0)
   , mBufferedHTTP1Consumed(0)
 {
-  mBufferedHTTP1 = new char[mBufferedHTTP1Size];
+  mBufferedHTTP1 = MakeUnique<char[]>(mBufferedHTTP1Size);
 }
 
 Http2PushTransactionBuffer::~Http2PushTransactionBuffer()
 {
   delete mRequestHead;
 }
 
 void
@@ -340,17 +340,17 @@ Http2PushTransactionBuffer::WriteSegment
                                           uint32_t count, uint32_t *countWritten)
 {
   if ((mBufferedHTTP1Size - mBufferedHTTP1Used) < 20480) {
     EnsureBuffer(mBufferedHTTP1,mBufferedHTTP1Size + kDefaultBufferSize,
                  mBufferedHTTP1Used, mBufferedHTTP1Size);
   }
 
   count = std::min(count, mBufferedHTTP1Size - mBufferedHTTP1Used);
-  nsresult rv = writer->OnWriteSegment(mBufferedHTTP1 + mBufferedHTTP1Used,
+  nsresult rv = writer->OnWriteSegment(&mBufferedHTTP1[mBufferedHTTP1Used],
                                        count, countWritten);
   if (NS_SUCCEEDED(rv)) {
     mBufferedHTTP1Used += *countWritten;
   }
   else if (rv == NS_BASE_STREAM_CLOSED) {
     mIsDone = true;
   }
 
@@ -427,17 +427,17 @@ Http2PushTransactionBuffer::PipelinePosi
 
 nsresult
 Http2PushTransactionBuffer::GetBufferedData(char *buf,
                                             uint32_t count,
                                             uint32_t *countWritten)
 {
   *countWritten = std::min(count, static_cast<uint32_t>(Available()));
   if (*countWritten) {
-    memcpy(buf, mBufferedHTTP1 + mBufferedHTTP1Consumed, *countWritten);
+    memcpy(buf, &mBufferedHTTP1[mBufferedHTTP1Consumed], *countWritten);
     mBufferedHTTP1Consumed += *countWritten;
   }
 
   // If all the data has been consumed then reset the buffer
   if (mBufferedHTTP1Consumed == mBufferedHTTP1Used) {
     mBufferedHTTP1Consumed = 0;
     mBufferedHTTP1Used = 0;
   }
--- a/netwerk/protocol/http/Http2Push.h
+++ b/netwerk/protocol/http/Http2Push.h
@@ -9,16 +9,17 @@
 // HTTP/2 - RFC 7540
 // https://www.rfc-editor.org/rfc/rfc7540.txt
 
 #include "Http2Session.h"
 #include "Http2Stream.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/UniquePtr.h"
 #include "nsHttpRequestHead.h"
 #include "nsILoadGroup.h"
 #include "nsISchedulingContext.h"
 #include "nsString.h"
 #include "PSpdyPush.h"
 
 namespace mozilla {
 namespace net {
@@ -109,17 +110,17 @@ private:
 
   const static uint32_t kDefaultBufferSize = 4096;
 
   nsresult mStatus;
   nsHttpRequestHead *mRequestHead;
   Http2PushedStream *mPushStream;
   bool mIsDone;
 
-  nsAutoArrayPtr<char> mBufferedHTTP1;
+  UniquePtr<char[]> mBufferedHTTP1;
   uint32_t mBufferedHTTP1Size;
   uint32_t mBufferedHTTP1Used;
   uint32_t mBufferedHTTP1Consumed;
 };
 
 } // namespace net
 } // namespace mozilla
 
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -113,18 +113,18 @@ Http2Session::Http2Session(nsISocketTran
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   static uint64_t sSerial;
   mSerial = ++sSerial;
 
   LOG3(("Http2Session::Http2Session %p serial=0x%X\n", this, mSerial));
 
-  mInputFrameBuffer = new char[mInputFrameBufferSize];
-  mOutputQueueBuffer = new char[mOutputQueueSize];
+  mInputFrameBuffer = MakeUnique<char[]>(mInputFrameBufferSize);
+  mOutputQueueBuffer = MakeUnique<char[]>(mOutputQueueSize);
   mDecompressBuffer.SetCapacity(kDefaultBufferSize);
   mDecompressor.SetCompressor(&mCompressor);
 
   mPushAllowance = gHttpHandler->SpdyPushAllowance();
   mInitialRwin = std::max(gHttpHandler->SpdyPullAllowance(), mPushAllowance);
   mMaxConcurrent = gHttpHandler->DefaultSpdyConcurrent();
   mSendingChunkSize = gHttpHandler->SpdySendingChunkSize();
   SendHello();
@@ -1149,17 +1149,17 @@ Http2Session::SetInputFrameDataStream(ui
   mInputFrameDataStream = nullptr;
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 Http2Session::ParsePadding(uint8_t &paddingControlBytes, uint16_t &paddingLength)
 {
   if (mInputFrameFlags & kFlag_PADDED) {
-    paddingLength = *reinterpret_cast<uint8_t *>(mInputFrameBuffer + kFrameHeaderBytes);
+    paddingLength = *reinterpret_cast<uint8_t *>(&mInputFrameBuffer[kFrameHeaderBytes]);
     paddingControlBytes = 1;
   } else {
     paddingLength = 0;
     paddingControlBytes = 0;
   }
 
   if (static_cast<uint32_t>(paddingLength + paddingControlBytes) > mInputFrameDataSize) {
     // This is fatal to the session
@@ -1230,17 +1230,17 @@ Http2Session::RecvHeaders(Http2Session *
 
     LOG3(("Http2Session::RecvHeaders %p lookup mInputFrameID stream "
           "0x%X failed. NextStreamID = 0x%X\n",
           self, self->mInputFrameID, self->mNextStreamID));
 
     if (self->mInputFrameID >= self->mNextStreamID)
       self->GenerateRstStream(PROTOCOL_ERROR, self->mInputFrameID);
 
-    self->mDecompressBuffer.Append(self->mInputFrameBuffer + kFrameHeaderBytes + paddingControlBytes + priorityLen,
+    self->mDecompressBuffer.Append(&self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes + priorityLen],
                                    self->mInputFrameDataSize - paddingControlBytes - priorityLen - paddingLength);
 
     if (self->mInputFrameFlags & kFlag_END_HEADERS) {
       rv = self->UncompressAndDiscard();
       if (NS_FAILED(rv)) {
         LOG3(("Http2Session::RecvHeaders uncompress failed\n"));
         // this is fatal to the session
         self->mGoAwayReason = COMPRESSION_ERROR;
@@ -1257,17 +1257,17 @@ Http2Session::RecvHeaders(Http2Session *
       !(self->mInputFrameFlags & kFlag_END_STREAM)) {
     // Any header block after the first that does *not* end the stream is
     // illegal.
     LOG3(("Http2Session::Illegal Extra HeaderBlock %p 0x%X\n", self, self->mInputFrameID));
     RETURN_SESSION_ERROR(self, PROTOCOL_ERROR);
   }
 
   // queue up any compression bytes
-  self->mDecompressBuffer.Append(self->mInputFrameBuffer + kFrameHeaderBytes + paddingControlBytes + priorityLen,
+  self->mDecompressBuffer.Append(&self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes + priorityLen],
                                  self->mInputFrameDataSize - paddingControlBytes - priorityLen - paddingLength);
 
   self->mInputFrameDataStream->UpdateTransportReadEvents(self->mInputFrameDataSize);
   self->mLastDataReadEpoch = self->mLastReadEpoch;
 
   if (!endHeadersFlag) { // more are coming - don't process yet
     self->ResetDownstreamState();
     return NS_OK;
@@ -1641,31 +1641,31 @@ Http2Session::RecvPushPromise(Http2Sessi
     } else {
       resetStream = false;
     }
   }
 
   if (resetStream) {
     // Need to decompress the headers even though we aren't using them yet in
     // order to keep the compression context consistent for other frames
-    self->mDecompressBuffer.Append(self->mInputFrameBuffer + kFrameHeaderBytes + paddingControlBytes + promiseLen,
+    self->mDecompressBuffer.Append(&self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes + promiseLen],
                                    self->mInputFrameDataSize - paddingControlBytes - promiseLen - paddingLength);
     if (self->mInputFrameFlags & kFlag_END_PUSH_PROMISE) {
       rv = self->UncompressAndDiscard();
       if (NS_FAILED(rv)) {
         LOG3(("Http2Session::RecvPushPromise uncompress failed\n"));
         self->mGoAwayReason = COMPRESSION_ERROR;
         return rv;
       }
     }
     self->ResetDownstreamState();
     return NS_OK;
   }
 
-  self->mDecompressBuffer.Append(self->mInputFrameBuffer + kFrameHeaderBytes + paddingControlBytes + promiseLen,
+  self->mDecompressBuffer.Append(&self->mInputFrameBuffer[kFrameHeaderBytes + paddingControlBytes + promiseLen],
                                  self->mInputFrameDataSize - paddingControlBytes - promiseLen - paddingLength);
 
   if (!(self->mInputFrameFlags & kFlag_END_PUSH_PROMISE)) {
     LOG3(("Http2Session::RecvPushPromise not finishing processing for multi-frame push\n"));
     self->ResetDownstreamState();
     return NS_OK;
   }
 
@@ -2498,30 +2498,30 @@ Http2Session::WriteSegments(nsAHttpSegme
       mDownstreamState == BUFFERING_FRAME_HEADER) {
     // The first 9 bytes of every frame is header information that
     // we are going to want to strip before passing to http. That is
     // true of both control and data packets.
 
     MOZ_ASSERT(mInputFrameBufferUsed < kFrameHeaderBytes,
                "Frame Buffer Used Too Large for State");
 
-    rv = NetworkRead(writer, mInputFrameBuffer + mInputFrameBufferUsed,
+    rv = NetworkRead(writer, &mInputFrameBuffer[mInputFrameBufferUsed],
                      kFrameHeaderBytes - mInputFrameBufferUsed, countWritten);
 
     if (NS_FAILED(rv)) {
       LOG3(("Http2Session %p buffering frame header read failure %x\n",
             this, rv));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
       return rv;
     }
 
     LogIO(this, nullptr, "Reading Frame Header",
-          mInputFrameBuffer + mInputFrameBufferUsed, *countWritten);
+          &mInputFrameBuffer[mInputFrameBufferUsed], *countWritten);
 
     mInputFrameBufferUsed += *countWritten;
 
     if (mInputFrameBufferUsed < kFrameHeaderBytes)
     {
       LOG3(("Http2Session::WriteSegments %p "
             "BUFFERING FRAME HEADER incomplete size=%d",
             this, mInputFrameBufferUsed));
@@ -2597,44 +2597,44 @@ Http2Session::WriteSegments(nsAHttpSegme
 
   if (mDownstreamState == PROCESSING_DATA_FRAME_PADDING_CONTROL) {
     MOZ_ASSERT(mInputFrameFlags & kFlag_PADDED,
                "Processing padding control on unpadded frame");
 
     MOZ_ASSERT(mInputFrameBufferUsed < (kFrameHeaderBytes + 1),
                "Frame buffer used too large for state");
 
-    rv = NetworkRead(writer, mInputFrameBuffer + mInputFrameBufferUsed,
+    rv = NetworkRead(writer, &mInputFrameBuffer[mInputFrameBufferUsed],
                      (kFrameHeaderBytes + 1) - mInputFrameBufferUsed,
                      countWritten);
 
     if (NS_FAILED(rv)) {
       LOG3(("Http2Session %p buffering data frame padding control read failure %x\n",
             this, rv));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
       return rv;
     }
 
     LogIO(this, nullptr, "Reading Data Frame Padding Control",
-          mInputFrameBuffer + mInputFrameBufferUsed, *countWritten);
+          &mInputFrameBuffer[mInputFrameBufferUsed], *countWritten);
 
     mInputFrameBufferUsed += *countWritten;
 
     if (mInputFrameBufferUsed - kFrameHeaderBytes < 1) {
       LOG3(("Http2Session::WriteSegments %p "
             "BUFFERING DATA FRAME CONTROL PADDING incomplete size=%d",
             this, mInputFrameBufferUsed - 8));
       return rv;
     }
 
     ++mInputFrameDataRead;
 
-    char *control = mInputFrameBuffer + kFrameHeaderBytes;
+    char *control = &mInputFrameBuffer[kFrameHeaderBytes];
     mPaddingLength = static_cast<uint8_t>(*control);
 
     LOG3(("Http2Session::WriteSegments %p stream 0x%X mPaddingLength=%d", this,
           mInputFrameID, mPaddingLength));
 
     if (1U + mPaddingLength == mInputFrameDataSize) {
       // This frame consists entirely of padding, we can just discard it
       LOG3(("Http2Session::WriteSegments %p stream 0x%X frame with only padding",
@@ -2786,30 +2786,30 @@ Http2Session::WriteSegments(nsAHttpSegme
     MOZ_ASSERT(false); // this cannot happen
     return NS_ERROR_UNEXPECTED;
   }
 
   MOZ_ASSERT(mInputFrameBufferUsed == kFrameHeaderBytes, "Frame Buffer Header Not Present");
   MOZ_ASSERT(mInputFrameDataSize + kFrameHeaderBytes <= mInputFrameBufferSize,
              "allocation for control frame insufficient");
 
-  rv = NetworkRead(writer, mInputFrameBuffer + kFrameHeaderBytes + mInputFrameDataRead,
+  rv = NetworkRead(writer, &mInputFrameBuffer[kFrameHeaderBytes + mInputFrameDataRead],
                    mInputFrameDataSize - mInputFrameDataRead, countWritten);
 
   if (NS_FAILED(rv)) {
     LOG3(("Http2Session %p buffering control frame read failure %x\n",
           this, rv));
     // maybe just blocked reading from network
     if (rv == NS_BASE_STREAM_WOULD_BLOCK)
       rv = NS_OK;
     return rv;
   }
 
   LogIO(this, nullptr, "Reading Control Frame",
-        mInputFrameBuffer + kFrameHeaderBytes + mInputFrameDataRead, *countWritten);
+        &mInputFrameBuffer[kFrameHeaderBytes + mInputFrameDataRead], *countWritten);
 
   mInputFrameDataRead += *countWritten;
 
   if (mInputFrameDataRead != mInputFrameDataSize)
     return NS_OK;
 
   MOZ_ASSERT(mInputFrameType != FRAME_TYPE_DATA);
   if (mInputFrameType < FRAME_TYPE_LAST) {
--- a/netwerk/protocol/http/Http2Session.h
+++ b/netwerk/protocol/http/Http2Session.h
@@ -6,16 +6,17 @@
 #ifndef mozilla_net_Http2Session_h
 #define mozilla_net_Http2Session_h
 
 // HTTP/2 - RFC 7540
 // https://www.rfc-editor.org/rfc/rfc7540.txt
 
 #include "ASpdySession.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAHttpConnection.h"
 #include "nsClassHashtable.h"
 #include "nsDataHashtable.h"
 #include "nsDeque.h"
 #include "nsHashKeys.h"
 
 #include "Http2Compression.h"
 
@@ -356,17 +357,17 @@ private:
   Http2Compressor     mCompressor;
   Http2Decompressor   mDecompressor;
   nsCString           mDecompressBuffer;
 
   // mInputFrameBuffer is used to store received control packets and the 8 bytes
   // of header on data packets
   uint32_t             mInputFrameBufferSize; // buffer allocation
   uint32_t             mInputFrameBufferUsed; // amt of allocation used
-  nsAutoArrayPtr<char> mInputFrameBuffer;
+  UniquePtr<char[]>    mInputFrameBuffer;
 
   // mInputFrameDataSize/Read are used for tracking the amount of data consumed
   // in a frame after the 8 byte header. Control frames are always fully buffered
   // and the fixed 8 byte leading header is at mInputFrameBuffer + 0, the first
   // data byte (i.e. the first settings/goaway/etc.. specific byte) is at
   // mInputFrameBuffer + 8
   // The frame size is mInputFrameDataSize + the constant 8 byte header
   uint32_t             mInputFrameDataSize;
@@ -468,17 +469,17 @@ private:
   // This is a output queue of bytes ready to be written to the SSL stream.
   // When that streams returns WOULD_BLOCK on direct write the bytes get
   // coalesced together here. This results in larger writes to the SSL layer.
   // The buffer is not dynamically grown to accomodate stream writes, but
   // does expand to accept infallible session wide frames like GoAway and RST.
   uint32_t             mOutputQueueSize;
   uint32_t             mOutputQueueUsed;
   uint32_t             mOutputQueueSent;
-  nsAutoArrayPtr<char> mOutputQueueBuffer;
+  UniquePtr<char[]>    mOutputQueueBuffer;
 
   PRIntervalTime       mPingThreshold;
   PRIntervalTime       mLastReadEpoch;     // used for ping timeouts
   PRIntervalTime       mLastDataReadEpoch; // used for IdleTime()
   PRIntervalTime       mPingSentEpoch;
 
   PRIntervalTime       mPreviousPingThreshold; // backup for the former value
   bool                 mPreviousUsed;          // true when backup is used
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -75,17 +75,17 @@ Http2Stream::Http2Stream(nsAHttpTransact
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   LOG3(("Http2Stream::Http2Stream %p", this));
 
   mServerReceiveWindow = session->GetServerInitialStreamWindow();
   mClientReceiveWindow = session->PushAllowance();
 
-  mTxInlineFrame = new uint8_t[mTxInlineFrameSize];
+  mTxInlineFrame = MakeUnique<uint8_t[]>(mTxInlineFrameSize);
 
   PR_STATIC_ASSERT(nsISupportsPriority::PRIORITY_LOWEST <= kNormalPriority);
 
   // values of priority closer to 0 are higher priority for the priority
   // argument. This value is used as a group, which maps to a
   // weight that is related to the nsISupportsPriority that we are given.
   int32_t httpPriority;
   if (priority >= nsISupportsPriority::PRIORITY_LOWEST) {
@@ -853,18 +853,17 @@ Http2Stream::TransmitFrame(const char *b
   // In the (relatively common) event that we have a small amount of data
   // split between the inlineframe and the streamframe, then move the stream
   // data into the inlineframe via copy in order to coalesce into one write.
   // Given the interaction with ssl this is worth the small copy cost.
   if (mTxStreamFrameSize && mTxInlineFrameUsed &&
       mTxStreamFrameSize < Http2Session::kDefaultBufferSize &&
       mTxInlineFrameUsed + mTxStreamFrameSize < mTxInlineFrameSize) {
     LOG3(("Coalesce Transmit"));
-    memcpy (mTxInlineFrame + mTxInlineFrameUsed,
-            buf, mTxStreamFrameSize);
+    memcpy (&mTxInlineFrame[mTxInlineFrameUsed], buf, mTxStreamFrameSize);
     if (countUsed)
       *countUsed += mTxStreamFrameSize;
     mTxInlineFrameUsed += mTxStreamFrameSize;
     mTxStreamFrameSize = 0;
   }
 
   rv =
     mSegmentReader->CommitToSegmentSize(mTxStreamFrameSize + mTxInlineFrameUsed,
--- a/netwerk/protocol/http/Http2Stream.h
+++ b/netwerk/protocol/http/Http2Stream.h
@@ -5,16 +5,17 @@
 
 #ifndef mozilla_net_Http2Stream_h
 #define mozilla_net_Http2Stream_h
 
 // HTTP/2 - RFC7540
 // https://www.rfc-editor.org/rfc/rfc7540.txt
 
 #include "mozilla/Attributes.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAHttpTransaction.h"
 #include "nsISupportsPriority.h"
 
 class nsStandardURL;
 
 namespace mozilla {
 namespace net {
 
@@ -261,17 +262,17 @@ private:
   uint32_t                     mSetTCPSocketBuffer   : 1;
 
   // Flag is set when OnWriteSegment is being called directly from stream instead
   // of transaction
   uint32_t                     mBypassInputBuffer   : 1;
 
   // The InlineFrame and associated data is used for composing control
   // frames and data frame headers.
-  nsAutoArrayPtr<uint8_t>      mTxInlineFrame;
+  UniquePtr<uint8_t[]>         mTxInlineFrame;
   uint32_t                     mTxInlineFrameSize;
   uint32_t                     mTxInlineFrameUsed;
 
   // mTxStreamFrameSize tracks the progress of
   // transmitting a request body data frame. The data frame itself
   // is never copied into the spdy layer.
   uint32_t                     mTxStreamFrameSize;
 
--- a/netwerk/protocol/http/SpdyPush31.cpp
+++ b/netwerk/protocol/http/SpdyPush31.cpp
@@ -178,17 +178,17 @@ SpdyPush31TransactionBuffer::SpdyPush31T
   : mStatus(NS_OK)
   , mRequestHead(nullptr)
   , mPushStream(nullptr)
   , mIsDone(false)
   , mBufferedHTTP1Size(kDefaultBufferSize)
   , mBufferedHTTP1Used(0)
   , mBufferedHTTP1Consumed(0)
 {
-  mBufferedHTTP1 = new char[mBufferedHTTP1Size];
+  mBufferedHTTP1 = MakeUnique<char[]>(mBufferedHTTP1Size);
 }
 
 SpdyPush31TransactionBuffer::~SpdyPush31TransactionBuffer()
 {
   delete mRequestHead;
 }
 
 void
@@ -269,17 +269,17 @@ SpdyPush31TransactionBuffer::WriteSegmen
                                            uint32_t count, uint32_t *countWritten)
 {
   if ((mBufferedHTTP1Size - mBufferedHTTP1Used) < 20480) {
     EnsureBuffer(mBufferedHTTP1, mBufferedHTTP1Size + kDefaultBufferSize,
                  mBufferedHTTP1Used, mBufferedHTTP1Size);
   }
 
   count = std::min(count, mBufferedHTTP1Size - mBufferedHTTP1Used);
-  nsresult rv = writer->OnWriteSegment(mBufferedHTTP1 + mBufferedHTTP1Used,
+  nsresult rv = writer->OnWriteSegment(&mBufferedHTTP1[mBufferedHTTP1Used],
                                        count, countWritten);
   if (NS_SUCCEEDED(rv)) {
     mBufferedHTTP1Used += *countWritten;
   }
   else if (rv == NS_BASE_STREAM_CLOSED) {
     mIsDone = true;
   }
 
@@ -356,17 +356,17 @@ SpdyPush31TransactionBuffer::PipelinePos
 
 nsresult
 SpdyPush31TransactionBuffer::GetBufferedData(char *buf,
                                                uint32_t count,
                                                uint32_t *countWritten)
 {
   *countWritten = std::min(count, static_cast<uint32_t>(Available()));
   if (*countWritten) {
-    memcpy(buf, mBufferedHTTP1 + mBufferedHTTP1Consumed, *countWritten);
+    memcpy(buf, &mBufferedHTTP1[mBufferedHTTP1Consumed], *countWritten);
     mBufferedHTTP1Consumed += *countWritten;
   }
 
   // If all the data has been consumed then reset the buffer
   if (mBufferedHTTP1Consumed == mBufferedHTTP1Used) {
     mBufferedHTTP1Consumed = 0;
     mBufferedHTTP1Used = 0;
   }
--- a/netwerk/protocol/http/SpdyPush31.h
+++ b/netwerk/protocol/http/SpdyPush31.h
@@ -5,16 +5,17 @@
 
 // spdy/3.1
 
 #ifndef mozilla_net_SpdyPush31_Internal_h
 #define mozilla_net_SpdyPush31_Internal_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/TimeStamp.h"
+#include "mozilla/UniquePtr.h"
 #include "nsHttpRequestHead.h"
 #include "nsISchedulingContext.h"
 #include "nsString.h"
 #include "PSpdyPush.h"
 #include "SpdySession31.h"
 #include "SpdyStream31.h"
 
 namespace mozilla {
@@ -85,17 +86,17 @@ private:
 
   const static uint32_t kDefaultBufferSize = 4096;
 
   nsresult mStatus;
   nsHttpRequestHead *mRequestHead;
   SpdyPushedStream31 *mPushStream;
   bool mIsDone;
 
-  nsAutoArrayPtr<char> mBufferedHTTP1;
+  UniquePtr<char[]> mBufferedHTTP1;
   uint32_t mBufferedHTTP1Size;
   uint32_t mBufferedHTTP1Used;
   uint32_t mBufferedHTTP1Consumed;
 };
 
 } // namespace net
 } // namespace mozilla
 
--- a/netwerk/protocol/http/SpdySession31.cpp
+++ b/netwerk/protocol/http/SpdySession31.cpp
@@ -74,18 +74,18 @@ SpdySession31::SpdySession31(nsISocketTr
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   static uint64_t sSerial;
   mSerial = ++sSerial;
 
   LOG3(("SpdySession31::SpdySession31 %p serial=0x%X\n", this, mSerial));
 
-  mInputFrameBuffer = new char[mInputFrameBufferSize];
-  mOutputQueueBuffer = new char[mOutputQueueSize];
+  mInputFrameBuffer = MakeUnique<char[]>(mInputFrameBufferSize);
+  mOutputQueueBuffer = MakeUnique<char[]>(mOutputQueueSize);
   zlibInit();
 
   mPushAllowance = gHttpHandler->SpdyPushAllowance();
   mMaxConcurrent = gHttpHandler->DefaultSpdyConcurrent();
   mSendingChunkSize = gHttpHandler->SpdySendingChunkSize();
   GenerateSettings();
 
   mLastDataReadEpoch = mLastReadEpoch;
@@ -640,17 +640,17 @@ SpdySession31::zlibInit()
 }
 
 // Need to decompress some data in order to keep the compression
 // context correct, but we really don't care what the result is
 nsresult
 SpdySession31::UncompressAndDiscard(uint32_t offset,
                                     uint32_t blockLen)
 {
-  char *blockStart = mInputFrameBuffer + offset;
+  char *blockStart = &mInputFrameBuffer[offset];
   unsigned char trash[2048];
   mDownstreamZlib.avail_in = blockLen;
   mDownstreamZlib.next_in = reinterpret_cast<unsigned char *>(blockStart);
   bool triedDictionary = false;
 
   do {
     mDownstreamZlib.next_out = trash;
     mDownstreamZlib.avail_out = sizeof(trash);
@@ -1118,17 +1118,17 @@ SpdySession31::HandleSynStream(SpdySessi
     self->CleanupStream(pushedStream, rv, RST_CANCEL);
     self->ResetDownstreamState();
     return NS_OK;
   }
 
   // Uncompress the response headers into a stream specific buffer, leaving them
   // in spdy format for the time being.
   rv = pushedStream->Uncompress(&self->mDownstreamZlib,
-                                self->mInputFrameBuffer + 18,
+                                &self->mInputFrameBuffer[18],
                                 self->mInputFrameDataSize - 10);
   if (NS_FAILED(rv)) {
     LOG(("SpdySession31::HandleSynStream uncompress failed\n"));
     return rv;
   }
 
   if (self->RegisterStreamID(pushedStream, streamID) == kDeadStreamID) {
     LOG(("SpdySession31::HandleSynStream registerstreamid failed\n"));
@@ -1222,17 +1222,17 @@ SpdySession31::HandleSynReply(SpdySessio
   }
 
   // Uncompress the headers into a stream specific buffer, leaving them in
   // spdy format for the time being. Make certain to do this
   // step before any error handling that might abort the stream but not
   // the session becuase the session compression context will become
   // inconsistent if all of the compressed data is not processed.
   rv = self->mInputFrameDataStream->Uncompress(&self->mDownstreamZlib,
-                                               self->mInputFrameBuffer + 12,
+                                               &self->mInputFrameBuffer[12],
                                                self->mInputFrameDataSize - 4);
 
   if (NS_FAILED(rv)) {
     LOG(("SpdySession31::HandleSynReply uncompress failed\n"));
     return rv;
   }
 
   if (self->mInputFrameDataStream->GetFullyOpen()) {
@@ -1589,17 +1589,17 @@ SpdySession31::HandleHeaders(SpdySession
   }
 
   // Uncompress the headers into local buffers in the SpdyStream, leaving
   // them in spdy format for the time being. Make certain to do this
   // step before any error handling that might abort the stream but not
   // the session becuase the session compression context will become
   // inconsistent if all of the compressed data is not processed.
   rv = self->mInputFrameDataStream->Uncompress(&self->mDownstreamZlib,
-                                               self->mInputFrameBuffer + 12,
+                                               &self->mInputFrameBuffer[12],
                                                self->mInputFrameDataSize - 4);
   if (NS_FAILED(rv)) {
     LOG(("SpdySession31::HandleHeaders uncompress failed\n"));
     return rv;
   }
 
   self->mInputFrameDataLast = self->mInputFrameBuffer[4] & kFlag_Data_FIN;
   self->mInputFrameDataStream->
@@ -1959,30 +1959,30 @@ SpdySession31::WriteSegments(nsAHttpSegm
   if (mDownstreamState == BUFFERING_FRAME_HEADER) {
     // The first 8 bytes of every frame is header information that
     // we are going to want to strip before passing to http. That is
     // true of both control and data packets.
 
     MOZ_ASSERT(mInputFrameBufferUsed < 8,
                "Frame Buffer Used Too Large for State");
 
-    rv = NetworkRead(writer, mInputFrameBuffer + mInputFrameBufferUsed,
+    rv = NetworkRead(writer, &mInputFrameBuffer[mInputFrameBufferUsed],
                      8 - mInputFrameBufferUsed, countWritten);
 
     if (NS_FAILED(rv)) {
       LOG3(("SpdySession31 %p buffering frame header read failure %x\n",
             this, rv));
       // maybe just blocked reading from network
       if (rv == NS_BASE_STREAM_WOULD_BLOCK)
         rv = NS_OK;
       return rv;
     }
 
     LogIO(this, nullptr, "Reading Frame Header",
-          mInputFrameBuffer + mInputFrameBufferUsed, *countWritten);
+          &mInputFrameBuffer[mInputFrameBufferUsed], *countWritten);
 
     mInputFrameBufferUsed += *countWritten;
 
     if (mInputFrameBufferUsed < 8)
     {
       LOG3(("SpdySession31::WriteSegments %p "
             "BUFFERING FRAME HEADER incomplete size=%d",
             this, mInputFrameBufferUsed));
@@ -2196,30 +2196,30 @@ SpdySession31::WriteSegments(nsAHttpSegm
   if (mDownstreamState != BUFFERING_CONTROL_FRAME) {
     // this cannot happen
     return NS_ERROR_UNEXPECTED;
   }
 
   MOZ_ASSERT(mInputFrameBufferUsed == 8,
              "Frame Buffer Header Not Present");
 
-  rv = NetworkRead(writer, mInputFrameBuffer + 8 + mInputFrameDataRead,
+  rv = NetworkRead(writer, &mInputFrameBuffer[8 + mInputFrameDataRead],
                    mInputFrameDataSize - mInputFrameDataRead, countWritten);
 
   if (NS_FAILED(rv)) {
     LOG3(("SpdySession31 %p buffering control frame read failure %x\n",
           this, rv));
     // maybe just blocked reading from network
     if (rv == NS_BASE_STREAM_WOULD_BLOCK)
       rv = NS_OK;
     return rv;
   }
 
   LogIO(this, nullptr, "Reading Control Frame",
-        mInputFrameBuffer + 8 + mInputFrameDataRead, *countWritten);
+        &mInputFrameBuffer[8 + mInputFrameDataRead], *countWritten);
 
   mInputFrameDataRead += *countWritten;
 
   if (mInputFrameDataRead != mInputFrameDataSize)
     return NS_OK;
 
   // This check is actually redundant, the control type was previously
   // checked to make sure it was in range, but we will check it again
--- a/netwerk/protocol/http/SpdySession31.h
+++ b/netwerk/protocol/http/SpdySession31.h
@@ -5,16 +5,17 @@
 
 #ifndef mozilla_net_SpdySession31_h
 #define mozilla_net_SpdySession31_h
 
 // spdy/3.1
 
 #include "ASpdySession.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAHttpConnection.h"
 #include "nsClassHashtable.h"
 #include "nsDataHashtable.h"
 #include "nsDeque.h"
 #include "nsHashKeys.h"
 #include "zlib.h"
 
 class nsISocketTransport;
@@ -302,17 +303,17 @@ private:
   // context correct.
   z_stream            mDownstreamZlib;
   z_stream            mUpstreamZlib;
 
   // mInputFrameBuffer is used to store received control packets and the 8 bytes
   // of header on data packets
   uint32_t             mInputFrameBufferSize;
   uint32_t             mInputFrameBufferUsed;
-  nsAutoArrayPtr<char> mInputFrameBuffer;
+  UniquePtr<char[]>    mInputFrameBuffer;
 
   // mInputFrameDataSize/Read are used for tracking the amount of data consumed
   // in a data frame. the data itself is not buffered in spdy
   // The frame size is mInputFrameDataSize + the constant 8 byte header
   uint32_t             mInputFrameDataSize;
   uint32_t             mInputFrameDataRead;
   bool                 mInputFrameDataLast; // This frame was marked FIN
 
@@ -390,17 +391,17 @@ private:
   // This is a output queue of bytes ready to be written to the SSL stream.
   // When that streams returns WOULD_BLOCK on direct write the bytes get
   // coalesced together here. This results in larger writes to the SSL layer.
   // The buffer is not dynamically grown to accomodate stream writes, but
   // does expand to accept infallible session wide frames like GoAway and RST.
   uint32_t             mOutputQueueSize;
   uint32_t             mOutputQueueUsed;
   uint32_t             mOutputQueueSent;
-  nsAutoArrayPtr<char> mOutputQueueBuffer;
+  UniquePtr<char[]>    mOutputQueueBuffer;
 
   PRIntervalTime       mPingThreshold;
   PRIntervalTime       mLastReadEpoch;     // used for ping timeouts
   PRIntervalTime       mLastDataReadEpoch; // used for IdleTime()
   PRIntervalTime       mPingSentEpoch;
   uint32_t             mNextPingID;
 
   PRIntervalTime       mPreviousPingThreshold; // backup for the former value
--- a/netwerk/protocol/http/SpdyStream31.cpp
+++ b/netwerk/protocol/http/SpdyStream31.cpp
@@ -72,18 +72,18 @@ SpdyStream31::SpdyStream31(nsAHttpTransa
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
 
   LOG3(("SpdyStream31::SpdyStream31 %p", this));
 
   mRemoteWindow = spdySession->GetServerInitialStreamWindow();
   mLocalWindow = spdySession->PushAllowance();
 
-  mTxInlineFrame = new uint8_t[mTxInlineFrameSize];
-  mDecompressBuffer = new char[mDecompressBufferSize];
+  mTxInlineFrame = MakeUnique<uint8_t[]>(mTxInlineFrameSize);
+  mDecompressBuffer = MakeUnique<char[]>(mDecompressBufferSize);
 }
 
 SpdyStream31::~SpdyStream31()
 {
   ClearTransactionsBlockedOnTunnel();
   mStreamID = SpdySession31::kDeadStreamID;
 }
 
@@ -376,21 +376,21 @@ SpdyStream31::GenerateSynFrame()
 
   mTxInlineFrame[0] = SpdySession31::kFlag_Control;
   mTxInlineFrame[1] = SpdySession31::kVersion;
   mTxInlineFrame[2] = 0;
   mTxInlineFrame[3] = SpdySession31::CONTROL_TYPE_SYN_STREAM;
   // 4 to 7 are length and flags, we'll fill that in later
 
   uint32_t networkOrderID = PR_htonl(mStreamID);
-  memcpy(mTxInlineFrame + 8, &networkOrderID, 4);
+  memcpy(&mTxInlineFrame[8], &networkOrderID, 4);
 
   // this is the associated-to field, which is not used sending
   // from the client in the http binding
-  memset (mTxInlineFrame + 12, 0, 4);
+  memset (&mTxInlineFrame[12], 0, 4);
 
   // Priority flags are the E0 mask of byte 16.
   // 0 is highest priority, 7 is lowest.
   // The other 5 bits of byte 16 are unused.
 
   if (mPriority >= nsISupportsPriority::PRIORITY_LOWEST)
     mTxInlineFrame[16] = 7 << 5;
   else if (mPriority <= nsISupportsPriority::PRIORITY_HIGHEST)
@@ -732,17 +732,17 @@ SpdyStream31::TransmitFrame(const char *
   // In the (relatively common) event that we have a small amount of data
   // split between the inlineframe and the streamframe, then move the stream
   // data into the inlineframe via copy in order to coalesce into one write.
   // Given the interaction with ssl this is worth the small copy cost.
   if (mTxStreamFrameSize && mTxInlineFrameUsed &&
       mTxStreamFrameSize < SpdySession31::kDefaultBufferSize &&
       mTxInlineFrameUsed + mTxStreamFrameSize < mTxInlineFrameSize) {
     LOG3(("Coalesce Transmit"));
-    memcpy (mTxInlineFrame + mTxInlineFrameUsed,
+    memcpy (&mTxInlineFrame[mTxInlineFrameUsed],
             buf, mTxStreamFrameSize);
     if (countUsed)
       *countUsed += mTxStreamFrameSize;
     mTxInlineFrameUsed += mTxStreamFrameSize;
     mTxStreamFrameSize = 0;
   }
 
   rv =
@@ -1383,17 +1383,17 @@ SpdyStream31::ExecuteCompress(uint32_t f
   {
     uint32_t avail = mTxInlineFrameSize - mTxInlineFrameUsed;
     if (avail < 1) {
       EnsureBuffer(mTxInlineFrame, mTxInlineFrameSize + 2000,
                    mTxInlineFrameUsed, mTxInlineFrameSize);
       avail = mTxInlineFrameSize - mTxInlineFrameUsed;
     }
 
-    mZlib->next_out = mTxInlineFrame + mTxInlineFrameUsed;
+    mZlib->next_out = &mTxInlineFrame[mTxInlineFrameUsed];
     mZlib->avail_out = avail;
     deflate(mZlib, flushMode);
     mTxInlineFrameUsed += avail - mZlib->avail_out;
   } while (mZlib->avail_in > 0 || !mZlib->avail_out);
 }
 
 void
 SpdyStream31::CompressToFrame(uint32_t data)
--- a/netwerk/protocol/http/SpdyStream31.h
+++ b/netwerk/protocol/http/SpdyStream31.h
@@ -2,16 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef mozilla_net_SpdyStream31_h
 #define mozilla_net_SpdyStream31_h
 
 #include "mozilla/Attributes.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAHttpTransaction.h"
 
 namespace mozilla { namespace net {
 
 class SpdyStream31 : public nsAHttpSegmentReader
                    , public nsAHttpSegmentWriter
 {
 public:
@@ -200,17 +201,17 @@ private:
   // Flag is set after TCP send autotuning has been disabled
   uint32_t                     mSetTCPSocketBuffer   : 1;
 
   // Flag is set when stream is counted towards MAX_CONCURRENT streams in session
   uint32_t                     mCountAsActive        : 1;
 
   // The InlineFrame and associated data is used for composing control
   // frames and data frame headers.
-  nsAutoArrayPtr<uint8_t>      mTxInlineFrame;
+  UniquePtr<uint8_t[]>         mTxInlineFrame;
   uint32_t                     mTxInlineFrameSize;
   uint32_t                     mTxInlineFrameUsed;
 
   // mTxStreamFrameSize tracks the progress of
   // transmitting a request body data frame. The data frame itself
   // is never copied into the spdy layer.
   uint32_t                     mTxStreamFrameSize;
 
@@ -219,17 +220,17 @@ private:
   //  to remain the same in all streams of a session.
   z_stream                     *mZlib;
   nsCString                    mFlatHttpRequestHeaders;
 
   // These are used for decompressing downstream spdy response headers
   uint32_t             mDecompressBufferSize;
   uint32_t             mDecompressBufferUsed;
   uint32_t             mDecompressedBytes;
-  nsAutoArrayPtr<char> mDecompressBuffer;
+  UniquePtr<char[]>    mDecompressBuffer;
 
   // Track the content-length of a request body so that we can
   // place the fin flag on the last data packet instead of waiting
   // for a stream closed indication. Relying on stream close results
   // in an extra 0-length runt packet and seems to have some interop
   // problems with the google servers. Connect does rely on stream
   // close by setting this to the max value.
   int64_t                      mRequestBodyLenRemaining;
--- a/netwerk/protocol/http/TunnelUtils.cpp
+++ b/netwerk/protocol/http/TunnelUtils.cpp
@@ -147,24 +147,24 @@ TLSFilterTransaction::OnReadSegment(cons
     // get rid of buffer first
   if (mEncryptedTextUsed) {
     rv = mSegmentReader->CommitToSegmentSize(mEncryptedTextUsed, mForce);
     if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
       return rv;
     }
 
     uint32_t amt;
-    rv = mSegmentReader->OnReadSegment(mEncryptedText, mEncryptedTextUsed, &amt);
+    rv = mSegmentReader->OnReadSegment(mEncryptedText.get(), mEncryptedTextUsed, &amt);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     mEncryptedTextUsed -= amt;
     if (mEncryptedTextUsed) {
-      memmove(mEncryptedText, mEncryptedText + amt, mEncryptedTextUsed);
+      memmove(mEncryptedText.get(), &mEncryptedText[amt], mEncryptedTextUsed);
       return NS_OK;
     }
   }
 
   // encrypt for network write
   // write aData down the SSL layer into the FilterWrite() method where it will
   // be queued into mEncryptedText. We need to copy it like this in order to
   // guarantee atomic writes
@@ -199,45 +199,45 @@ TLSFilterTransaction::OnReadSegment(cons
 
   uint32_t amt = 0;
   if (mEncryptedTextUsed) {
     // If we are tunneled on spdy CommitToSegmentSize will prevent partial
     // writes that could interfere with multiplexing. H1 is fine with
     // partial writes.
     rv = mSegmentReader->CommitToSegmentSize(mEncryptedTextUsed, mForce);
     if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
-      rv = mSegmentReader->OnReadSegment(mEncryptedText, mEncryptedTextUsed, &amt);
+      rv = mSegmentReader->OnReadSegment(mEncryptedText.get(), mEncryptedTextUsed, &amt);
     }
 
     if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
       // return OK because all the data was consumed and stored in this buffer
       Connection()->TransactionHasDataToWrite(this);
       return NS_OK;
     } else if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   if (amt == mEncryptedTextUsed) {
     mEncryptedText = nullptr;
     mEncryptedTextUsed = 0;
     mEncryptedTextSize = 0;
   } else {
-    memmove(mEncryptedText, mEncryptedText + amt, mEncryptedTextUsed - amt);
+    memmove(mEncryptedText.get(), &mEncryptedText[amt], mEncryptedTextUsed - amt);
     mEncryptedTextUsed -= amt;
   }
   return NS_OK;
 }
 
 int32_t
 TLSFilterTransaction::FilterOutput(const char *aBuf, int32_t aAmount)
 {
   EnsureBuffer(mEncryptedText, mEncryptedTextUsed + aAmount,
                mEncryptedTextUsed, mEncryptedTextSize);
-  memcpy(mEncryptedText + mEncryptedTextUsed, aBuf, aAmount);
+  memcpy(&mEncryptedText[mEncryptedTextUsed], aBuf, aAmount);
   mEncryptedTextUsed += aAmount;
   return aAmount;
 }
 
 nsresult
 TLSFilterTransaction::CommitToSegmentSize(uint32_t size, bool forceCommitment)
 {
   if (!mSegmentReader) {
@@ -1096,17 +1096,17 @@ SpdyConnectTransaction::Flush(uint32_t c
   if (!mSegmentReader) {
     return NS_ERROR_UNEXPECTED;
   }
 
   *countRead = 0;
   count = std::min(count, (mOutputDataUsed - mOutputDataOffset));
   if (count) {
     nsresult rv;
-    rv = mSegmentReader->OnReadSegment(mOutputData + mOutputDataOffset,
+    rv = mSegmentReader->OnReadSegment(&mOutputData[mOutputDataOffset],
                                        count, countRead);
     if (NS_FAILED(rv) && (rv != NS_BASE_STREAM_WOULD_BLOCK)) {
       LOG(("SpdyConnectTransaction::Flush %p Error %x\n", this, rv));
       CreateShimError(rv);
       return rv;
     }
   }
 
@@ -1223,17 +1223,17 @@ SpdyConnectTransaction::WriteSegments(ns
 {
   MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
   LOG(("SpdyConnectTransaction::WriteSegments %p max=%d cb=%p\n",
        this, count, mTunneledConn ? mTunnelStreamIn->mCallback : nullptr));
 
   // first call into the tunnel stream to get the demux'd data out of the
   // spdy session.
   EnsureBuffer(mInputData, mInputDataUsed + count, mInputDataUsed, mInputDataSize);
-  nsresult rv = writer->OnWriteSegment(mInputData + mInputDataUsed,
+  nsresult rv = writer->OnWriteSegment(&mInputData[mInputDataUsed],
                                        count, countWritten);
   if (NS_FAILED(rv)) {
     if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
       LOG(("SpdyConnectTransaction::WriteSegments wrapped writer %p Error %x\n", this, rv));
       CreateShimError(rv);
     }
     return rv;
   }
@@ -1383,18 +1383,17 @@ OutputStreamShim::Write(const char * aBu
   if ((trans->mOutputDataUsed + aCount) >= 512000) {
     *_retval = 0;
     // time for some flow control;
     return NS_BASE_STREAM_WOULD_BLOCK;
   }
 
   EnsureBuffer(trans->mOutputData, trans->mOutputDataUsed + aCount,
                trans->mOutputDataUsed, trans->mOutputDataSize);
-  memcpy(trans->mOutputData + trans->mOutputDataUsed,
-          aBuf, aCount);
+  memcpy(&trans->mOutputData[trans->mOutputDataUsed], aBuf, aCount);
   trans->mOutputDataUsed += aCount;
   *_retval = aCount;
   LOG(("OutputStreamShim::Write %p new %d total %d\n", this, aCount, trans->mOutputDataUsed));
 
   trans->mSession->TransactionHasDataToWrite(trans);
 
   return NS_OK;
 }
@@ -1492,17 +1491,17 @@ InputStreamShim::Read(char *aBuf, uint32
   MOZ_ASSERT(trans);
   if (!trans) {
     return NS_ERROR_UNEXPECTED;
   }
 
   uint32_t avail = trans->mInputDataUsed - trans->mInputDataOffset;
   uint32_t tocopy = std::min(aCount, avail);
   *_retval = tocopy;
-  memcpy(aBuf, trans->mInputData + trans->mInputDataOffset, tocopy);
+  memcpy(aBuf, &trans->mInputData[trans->mInputDataOffset], tocopy);
   trans->mInputDataOffset += tocopy;
   if (trans->mInputDataOffset == trans->mInputDataUsed) {
     trans->mInputDataOffset = trans->mInputDataUsed = 0;
   }
 
   return tocopy ? NS_OK : NS_BASE_STREAM_WOULD_BLOCK;
 }
 
--- a/netwerk/protocol/http/TunnelUtils.h
+++ b/netwerk/protocol/http/TunnelUtils.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef mozilla_net_TLSFilterTransaction_h
 #define mozilla_net_TLSFilterTransaction_h
 
 #include "mozilla/Attributes.h"
+#include "mozilla/UniquePtr.h"
 #include "nsAHttpTransaction.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIAsyncOutputStream.h"
 #include "nsISocketTransport.h"
 #include "nsITimer.h"
 #include "NullHttpTransaction.h"
 #include "mozilla/TimeStamp.h"
 #include "prio.h"
@@ -152,17 +153,17 @@ private:
 
 private:
   RefPtr<nsAHttpTransaction> mTransaction;
   nsCOMPtr<nsISupports> mSecInfo;
   nsCOMPtr<nsITimer> mTimer;
   RefPtr<NudgeTunnelCallback> mNudgeCallback;
 
   // buffered network output, after encryption
-  nsAutoArrayPtr<char> mEncryptedText;
+  UniquePtr<char[]> mEncryptedText;
   uint32_t mEncryptedTextUsed;
   uint32_t mEncryptedTextSize;
 
   PRFileDesc *mFD;
   nsAHttpSegmentReader *mSegmentReader;
   nsAHttpSegmentWriter *mSegmentWriter;
 
   nsresult mFilterReadCode;
@@ -213,22 +214,22 @@ private:
   void CreateShimError(nsresult code);
 
   nsCString             mConnectString;
   uint32_t              mConnectStringOffset;
 
   nsAHttpConnection    *mSession;
   nsAHttpSegmentReader *mSegmentReader;
 
-  nsAutoArrayPtr<char> mInputData;
+  UniquePtr<char[]>   mInputData;
   uint32_t             mInputDataSize;
   uint32_t             mInputDataUsed;
   uint32_t             mInputDataOffset;
 
-  nsAutoArrayPtr<char> mOutputData;
+  UniquePtr<char[]>    mOutputData;
   uint32_t             mOutputDataSize;
   uint32_t             mOutputDataUsed;
   uint32_t             mOutputDataOffset;
 
   bool                           mForcePlainText;
   TimeStamp                      mTimestampSyn;
   RefPtr<nsHttpConnectionInfo> mConnInfo;
 
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -314,43 +314,43 @@ nsHttp::ParseInt64(const char *input, co
 bool
 nsHttp::IsPermanentRedirect(uint32_t httpStatus)
 {
   return httpStatus == 301 || httpStatus == 308;
 }
 
 
 template<typename T> void
-localEnsureBuffer(nsAutoArrayPtr<T> &buf, uint32_t newSize,
+localEnsureBuffer(UniquePtr<T[]> &buf, uint32_t newSize,
              uint32_t preserve, uint32_t &objSize)
 {
   if (objSize >= newSize)
     return;
 
   // Leave a little slop on the new allocation - add 2KB to
   // what we need and then round the result up to a 4KB (page)
   // boundary.
 
   objSize = (newSize + 2048 + 4095) & ~4095;
 
   static_assert(sizeof(T) == 1, "sizeof(T) must be 1");
-  nsAutoArrayPtr<T> tmp(new T[objSize]);
+  auto tmp = MakeUnique<T[]>(objSize);
   if (preserve) {
-    memcpy(tmp, buf, preserve);
+    memcpy(tmp.get(), buf.get(), preserve);
   }
-  buf = tmp;
+  buf = Move(tmp);
 }
 
-void EnsureBuffer(nsAutoArrayPtr<char> &buf, uint32_t newSize,
+void EnsureBuffer(UniquePtr<char[]> &buf, uint32_t newSize,
                   uint32_t preserve, uint32_t &objSize)
 {
     localEnsureBuffer<char> (buf, newSize, preserve, objSize);
 }
 
-void EnsureBuffer(nsAutoArrayPtr<uint8_t> &buf, uint32_t newSize,
+void EnsureBuffer(UniquePtr<uint8_t[]> &buf, uint32_t newSize,
                   uint32_t preserve, uint32_t &objSize)
 {
     localEnsureBuffer<uint8_t> (buf, newSize, preserve, objSize);
 }
 ///
 
 void
 ParsedHeaderValueList::Tokenize(char *input, uint32_t inputLen, char **token,
--- a/netwerk/protocol/http/nsHttp.h
+++ b/netwerk/protocol/http/nsHttp.h
@@ -8,16 +8,17 @@
 #define nsHttp_h__
 
 #include <stdint.h>
 #include "prtime.h"
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsError.h"
 #include "nsTArray.h"
+#include "mozilla/UniquePtr.h"
 
 // http version codes
 #define NS_HTTP_VERSION_UNKNOWN  0
 #define NS_HTTP_VERSION_0_9      9
 #define NS_HTTP_VERSION_1_0     10
 #define NS_HTTP_VERSION_1_1     11
 #define NS_HTTP_VERSION_2_0     20
 
@@ -194,19 +195,19 @@ PRTimeToSeconds(PRTime t_usec)
 #define NowInSeconds() PRTimeToSeconds(PR_Now())
 
 // Round q-value to 2 decimal places; return 2 most significant digits as uint.
 #define QVAL_TO_UINT(q) ((unsigned int) ((q + 0.005) * 100.0))
 
 #define HTTP_LWS " \t"
 #define HTTP_HEADER_VALUE_SEPS HTTP_LWS ","
 
-void EnsureBuffer(nsAutoArrayPtr<char> &buf, uint32_t newSize,
+void EnsureBuffer(UniquePtr<char[]> &buf, uint32_t newSize,
                   uint32_t preserve, uint32_t &objSize);
-void EnsureBuffer(nsAutoArrayPtr<uint8_t> &buf, uint32_t newSize,
+void EnsureBuffer(UniquePtr<uint8_t[]> &buf, uint32_t newSize,
                   uint32_t preserve, uint32_t &objSize);
 
 // h2=":443"; ma=60; single
 // results in 3 mValues = {{h2, :443}, {ma, 60}, {single}}
 
 class ParsedHeaderPair
 {
 public:
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -7,23 +7,24 @@
 #include "nsMemory.h"
 #include "plstr.h"
 #include "mozilla/Logging.h"
 #include "nsCOMPtr.h"
 #include "nsEscape.h"
 #include "nsStringStream.h"
 #include "nsIStreamListener.h"
 #include "nsCRT.h"
-#include "nsAutoPtr.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 
 #include "ParseFTPList.h"
 #include <algorithm>
 
+#include "mozilla/UniquePtrExtensions.h"
+
 //
 // Log module for FTP dir listing stream converter logging...
 //
 // To enable logging (see prlog.h for full details):
 //
 //    set NSPR_LOG_MODULES=nsFTPDirListConv:5
 //    set NSPR_LOG_FILE=nspr.log
 //
@@ -80,59 +81,59 @@ nsFTPDirListingConv::OnDataAvailable(nsI
     
     uint32_t read, streamLen;
 
     uint64_t streamLen64;
     rv = inStr->Available(&streamLen64);
     NS_ENSURE_SUCCESS(rv, rv);
     streamLen = (uint32_t)std::min(streamLen64, uint64_t(UINT32_MAX - 1));
 
-    nsAutoArrayPtr<char> buffer(new char[streamLen + 1]);
+    auto buffer = MakeUniqueFallible<char[]>(streamLen + 1);
     NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
 
-    rv = inStr->Read(buffer, streamLen, &read);
+    rv = inStr->Read(buffer.get(), streamLen, &read);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // the dir listings are ascii text, null terminate this sucker.
     buffer[streamLen] = '\0';
 
     MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("nsFTPDirListingConv::OnData(request = %x, ctxt = %x, inStr = %x, sourceOffset = %llu, count = %u)\n", request, ctxt, inStr, sourceOffset, count));
 
     if (!mBuffer.IsEmpty()) {
         // we have data left over from a previous OnDataAvailable() call.
         // combine the buffers so we don't lose any data.
-        mBuffer.Append(buffer);
+        mBuffer.Append(buffer.get());
 
-        buffer = new char[mBuffer.Length()+1];
+        buffer = MakeUniqueFallible<char[]>(mBuffer.Length()+1);
         NS_ENSURE_TRUE(buffer, NS_ERROR_OUT_OF_MEMORY);
 
-        strncpy(buffer, mBuffer.get(), mBuffer.Length()+1);
+        strncpy(buffer.get(), mBuffer.get(), mBuffer.Length()+1);
         mBuffer.Truncate();
     }
 
 #ifndef DEBUG_dougt
     MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() received the following %d bytes...\n\n%s\n\n", streamLen, buffer.get()) );
 #else
-    printf("::OnData() received the following %d bytes...\n\n%s\n\n", streamLen, buffer);
+    printf("::OnData() received the following %d bytes...\n\n%s\n\n", streamLen, buffer.get());
 #endif // DEBUG_dougt
 
     nsAutoCString indexFormat;
     if (!mSentHeading) {
         // build up the 300: line
         nsCOMPtr<nsIURI> uri;
         rv = channel->GetURI(getter_AddRefs(uri));
         NS_ENSURE_SUCCESS(rv, rv);
 
         rv = GetHeaders(indexFormat, uri);
         NS_ENSURE_SUCCESS(rv, rv);
 
         mSentHeading = true;
     }
 
-    char *line = buffer;
+    char *line = buffer.get();
     line = DigestBufferLines(line, indexFormat);
 
 #ifndef DEBUG_dougt
     MOZ_LOG(gFTPDirListConvLog, LogLevel::Debug, ("::OnData() sending the following %d bytes...\n\n%s\n\n", 
         indexFormat.Length(), indexFormat.get()) );
 #else
     char *unescData = ToNewCString(indexFormat);
     NS_ENSURE_TRUE(unescData, NS_ERROR_OUT_OF_MEMORY);
--- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp
@@ -5,16 +5,18 @@
 
 #include "nsTXTToHTMLConv.h"
 #include "nsEscape.h"
 #include "nsStringStream.h"
 #include "nsAutoPtr.h"
 #include "nsIChannel.h"
 #include <algorithm>
 
+#include "mozilla/UniquePtrExtensions.h"
+
 #define TOKEN_DELIMITERS MOZ_UTF16("\t\r\n ")
 
 // nsISupports methods
 NS_IMPL_ISUPPORTS(nsTXTToHTMLConv,
                   nsIStreamConverter,
                   nsITXTToHTMLConv,
                   nsIRequestObserver,
                   nsIStreamListener)
@@ -128,28 +130,28 @@ nsTXTToHTMLConv::PreFormatHTML(bool valu
 NS_IMETHODIMP
 nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext,
                                  nsIInputStream *aInStream,
                                  uint64_t aOffset, uint32_t aCount)
 {
     nsresult rv = NS_OK;
     nsString pushBuffer;
     uint32_t amtRead = 0;
-    nsAutoArrayPtr<char> buffer(new char[aCount+1]);
+    auto buffer = MakeUniqueFallible<char[]>(aCount+1);
     if (!buffer) return NS_ERROR_OUT_OF_MEMORY;
 
     do {
         uint32_t read = 0;
         // XXX readSegments, to avoid the first copy?
-        rv = aInStream->Read(buffer, aCount-amtRead, &read);
+        rv = aInStream->Read(buffer.get(), aCount-amtRead, &read);
         if (NS_FAILED(rv)) return rv;
 
         buffer[read] = '\0';
         // XXX charsets?? non-latin1 characters?? utf-16??
-        AppendASCIItoUTF16(buffer, mBuffer);
+        AppendASCIItoUTF16(buffer.get(), mBuffer);
         amtRead += read;
 
         int32_t front = -1, back = -1, tokenLoc = -1, cursor = 0;
 
         while ( (tokenLoc = FindToken(cursor, &mToken)) > -1) {
             if (mToken->prepend) {
                 front = mBuffer.RFindCharInSet(TOKEN_DELIMITERS, tokenLoc);
                 front++;