Bug 1286170 - Handle move-assignment of SourceBufferIterators correctly. r=edwin
authorSeth Fowler <mark.seth.fowler@gmail.com>
Tue, 12 Jul 2016 00:45:01 -0700
changeset 388584 8033580f6a1d20abe8635ad724866475631263e6
parent 388583 a5c17d3e26c6316d407221e38cd529101cd449b5
child 388585 ab4ae8b37941493a3ec12506d28fc82ec3bf5c34
push id23207
push userrthijssen@mozilla.com
push dateSat, 16 Jul 2016 09:33:55 +0000
reviewersedwin
bugs1286170
milestone50.0a1
Bug 1286170 - Handle move-assignment of SourceBufferIterators correctly. r=edwin
image/SourceBuffer.cpp
image/SourceBuffer.h
--- a/image/SourceBuffer.cpp
+++ b/image/SourceBuffer.cpp
@@ -25,16 +25,32 @@ namespace image {
 
 SourceBufferIterator::~SourceBufferIterator()
 {
   if (mOwner) {
     mOwner->OnIteratorRelease();
   }
 }
 
+SourceBufferIterator&
+SourceBufferIterator::operator=(SourceBufferIterator&& aOther)
+{
+  if (mOwner) {
+    mOwner->OnIteratorRelease();
+  }
+
+  mOwner = Move(aOther.mOwner);
+  mState = aOther.mState;
+  mData = aOther.mData;
+  mChunkCount = aOther.mChunkCount;
+  mByteCount = aOther.mByteCount;
+
+  return *this;
+}
+
 SourceBufferIterator::State
 SourceBufferIterator::AdvanceOrScheduleResume(IResumable* aConsumer)
 {
   MOZ_ASSERT(mOwner);
   return mOwner->AdvanceIteratorOrScheduleResume(*this, aConsumer);
 }
 
 bool
--- a/image/SourceBuffer.h
+++ b/image/SourceBuffer.h
@@ -95,25 +95,17 @@ public:
     , mState(aOther.mState)
     , mData(aOther.mData)
     , mChunkCount(aOther.mChunkCount)
     , mByteCount(aOther.mByteCount)
   { }
 
   ~SourceBufferIterator();
 
-  SourceBufferIterator& operator=(SourceBufferIterator&& aOther)
-  {
-    mOwner = Move(aOther.mOwner);
-    mState = aOther.mState;
-    mData = aOther.mData;
-    mChunkCount = aOther.mChunkCount;
-    mByteCount = aOther.mByteCount;
-    return *this;
-  }
+  SourceBufferIterator& operator=(SourceBufferIterator&& aOther);
 
   /**
    * Returns true if there are no more than @aBytes remaining in the
    * SourceBuffer. If the SourceBuffer is not yet complete, returns false.
    */
   bool RemainingBytesIsNoMoreThan(size_t aBytes) const;
 
   /**