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 345198 d22b7fe7acebd24a32a4b3ce52e5deaadc9dd804
parent 345197 5621495f210234a1f8969a883a753675e8ce8a03
child 345199 3ddd65b25581c8697d80f18a94f1569bd32df5e1
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [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 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");