Bug 1156109 - Make nsStorageInputStream::mStorageStream an nsRefPtr; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 19 Apr 2015 14:54:58 -0400
changeset 240044 4054f6ba3ad92520283448d0f48c43907f23a487
parent 240043 0b070d503800e1681c8051442eba8b83eecbd8ff
child 240045 3596a743128555c799887c21094f8127597b846c
push id12477
push userkwierso@gmail.com
push dateTue, 21 Apr 2015 00:19:58 +0000
treeherderfx-team@03c1c4c133d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1156109
milestone40.0a1
Bug 1156109 - Make nsStorageInputStream::mStorageStream an nsRefPtr; r=froydnj
xpcom/io/nsStorageStream.cpp
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -346,38 +346,36 @@ class nsStorageInputStream final
 {
 public:
   nsStorageInputStream(nsStorageStream* aStorageStream, uint32_t aSegmentSize)
     : mStorageStream(aStorageStream), mReadCursor(0),
       mSegmentEnd(0), mSegmentNum(0),
       mSegmentSize(aSegmentSize), mLogicalCursor(0),
       mStatus(NS_OK)
   {
-    NS_ADDREF(mStorageStream);
   }
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIINPUTSTREAM
   NS_DECL_NSISEEKABLESTREAM
   NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
   NS_DECL_NSICLONEABLEINPUTSTREAM
 
 private:
   ~nsStorageInputStream()
   {
-    NS_IF_RELEASE(mStorageStream);
   }
 
 protected:
   NS_METHOD Seek(uint32_t aPosition);
 
   friend class nsStorageStream;
 
 private:
-  nsStorageStream* mStorageStream;
+  nsRefPtr<nsStorageStream> mStorageStream;
   uint32_t         mReadCursor;    // Next memory location to read byte, or 0
   uint32_t         mSegmentEnd;    // One byte past end of current buffer segment
   uint32_t         mSegmentNum;    // Segment number containing read cursor
   uint32_t         mSegmentSize;   // All segments, except the last, are of this size
   uint32_t         mLogicalCursor; // Logical offset into stream
   nsresult         mStatus;
 
   uint32_t SegNum(uint32_t aPosition)