Bug 1285867 (Part 5) - Replace Decoder::mDataDone with Decoder::mReachedTerminalState. r=edwin
authorSeth Fowler <mark.seth.fowler@gmail.com>
Mon, 11 Jul 2016 00:42:56 -0700
changeset 305170 4840df0f7046913f4582487522b4ff73ceef96c0
parent 305169 3ddd65b25581c8697d80f18a94f1569bd32df5e1
child 305171 9b650c8855c2a64e6194680eee53c53b113e4798
push id30455
push usercbook@mozilla.com
push dateSun, 17 Jul 2016 08:08:29 +0000
treeherdermozilla-central@711963e8daa3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1285867
milestone50.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 1285867 (Part 5) - Replace Decoder::mDataDone with Decoder::mReachedTerminalState. r=edwin
image/Decoder.cpp
image/Decoder.h
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -60,17 +60,17 @@ Decoder::Decoder(RasterImage* aImage)
   , mFrameCount(0)
   , mChunkCount(0)
   , mDecoderFlags(DefaultDecoderFlags())
   , mSurfaceFlags(DefaultSurfaceFlags())
   , mBytesDecoded(0)
   , mInitialized(false)
   , mMetadataDecode(false)
   , mInFrame(false)
-  , mDataDone(false)
+  , mReachedTerminalState(false)
   , mDecodeDone(false)
   , mDataError(false)
   , mDecodeAborted(false)
   , mShouldReportError(false)
 { }
 
 Decoder::~Decoder()
 {
@@ -138,18 +138,16 @@ Decoder::Decode(NotNull<IResumable*> aOn
       case SourceBufferIterator::WAITING:
         // We can't continue because the rest of the data hasn't arrived from
         // the network yet. We don't have to do anything special; the
         // SourceBufferIterator will ensure that Decode() gets called again on a
         // DecodePool thread when more data is available.
         return NS_OK;
 
       case SourceBufferIterator::COMPLETE:
-        mDataDone = true;
-
         // Normally even if the data is truncated, we want decoding to
         // succeed so we can display whatever we got. However, if the
         // SourceBuffer was completed with a failing status, we want to fail.
         // This happens only in exceptional situations like SourceBuffer
         // itself encountering a failure due to OOM.
         terminalState = NS_SUCCEEDED(mIterator->CompletionStatus())
                       ? Some(TerminalState::SUCCESS)
                       : Some(TerminalState::FAILURE);
@@ -170,16 +168,17 @@ Decoder::Decode(NotNull<IResumable*> aOn
 
       default:
         MOZ_ASSERT_UNREACHABLE("Unknown SourceBufferIterator state");
         terminalState = Some(TerminalState::FAILURE);
     }
   } while (!terminalState);
 
   MOZ_ASSERT(terminalState);
+  mReachedTerminalState = true;
 
   // If decoding failed, record that fact.
   if (terminalState == Some(TerminalState::FAILURE)) {
     PostDataError();
   }
 
   // We're done decoding; perform final cleanup.
   CompleteDecode();
--- a/image/Decoder.h
+++ b/image/Decoder.h
@@ -188,18 +188,18 @@ public:
   // Error tracking
   bool HasError() const { return HasDataError(); }
   bool HasDataError() const { return mDataError; }
   bool ShouldReportError() const { return mShouldReportError; }
 
   /// Did we finish decoding enough that calling Decode() again would be useless?
   bool GetDecodeDone() const
   {
-    return mDecodeDone || (mMetadataDecode && HasSize()) ||
-           HasError() || mDataDone;
+    return mReachedTerminalState || mDecodeDone ||
+           (mMetadataDecode && HasSize()) || HasError();
   }
 
   /// Are we in the middle of a frame right now? Used for assertions only.
   bool InFrame() const { return mInFrame; }
 
   /// Should we store surfaces created by this decoder in the SurfaceCache?
   bool ShouldUseSurfaceCache() const { return bool(mImage); }
 
@@ -420,17 +420,17 @@ private:
 
   DecoderFlags mDecoderFlags;
   SurfaceFlags mSurfaceFlags;
   size_t mBytesDecoded;
 
   bool mInitialized : 1;
   bool mMetadataDecode : 1;
   bool mInFrame : 1;
-  bool mDataDone : 1;
+  bool mReachedTerminalState : 1;
   bool mDecodeDone : 1;
   bool mDataError : 1;
   bool mDecodeAborted : 1;
   bool mShouldReportError : 1;
 };
 
 } // namespace image
 } // namespace mozilla