Bug 1285867 (Part 3f) - Only call PostDataError() outside the loop. r=edwin
authorSeth Fowler <mark.seth.fowler@gmail.com>
Mon, 11 Jul 2016 23:23:09 -0700
changeset 330232 d22b7fe7acebd24a32a4b3ce52e5deaadc9dd804
parent 330231 5621495f210234a1f8969a883a753675e8ce8a03
child 330233 3ddd65b25581c8697d80f18a94f1569bd32df5e1
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1285867
milestone50.0a1
Bug 1285867 (Part 3f) - Only call PostDataError() outside the loop. r=edwin
image/Decoder.cpp
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -143,22 +143,17 @@ Decoder::Decode(NotNull<IResumable*> aOn
         // 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);
 
-        if (terminalState == Some(TerminalState::FAILURE)) {
-          PostDataError();
-        }
-
-        CompleteDecode();
-        return terminalState == Some(TerminalState::SUCCESS) ? NS_OK : NS_ERROR_FAILURE;
+        break;
 
       case SourceBufferIterator::READY: {
         PROFILER_LABEL("ImageDecoder", "Decode",
                        js::ProfileEntry::Category::GRAPHICS);
 
         AutoRecordDecoderTelemetry telemetry(this, mIterator->Length());
 
         // Pass the data along to the implementation.
@@ -173,17 +168,21 @@ Decoder::Decode(NotNull<IResumable*> aOn
     }
   } while (!GetDecodeDone() && !terminalState);
 
   // If decoding failed, record that fact.
   if (terminalState == Some(TerminalState::FAILURE)) {
     PostDataError();
   }
 
-  CompleteDecode();
+  // If we're done decoding, perform final cleanup.
+  if (terminalState) {
+    CompleteDecode();
+  }
+
   return HasError() ? NS_ERROR_FAILURE : NS_OK;
 }
 
 bool
 Decoder::ShouldSyncDecode(size_t aByteLimit)
 {
   MOZ_ASSERT(aByteLimit > 0);
   MOZ_ASSERT(mIterator, "Should have a SourceBufferIterator");