[go: nahoru, domu]

Replace DecodeStatus with Status in DecodeCB.

This is the first of several CLs to replace DecodeStatus with
media::Status.  This one adjusts DecodeCB to return a Status, and
alters the consumers to expect it.  It also adds the DecodeStatus
enum values to StatusCode, so that old code continues to work
without modification.  DecodeStatus is aliased to StatusCode.

DecodeCB implementations have been modified to check for "not
ok, not aborted" where they used to check for
`DecodeStatus::DECODE_ERROR`.  While `DECODE_ERROR` is still defined
in the enum, and decoders continue to return it, the consumers
should now work even if individual decoders start sending more
detailed status codes.  `DECODE_ERROR` will be removed once all the
decoders have been updated.

For tests, there is now a `IsDecodeErrorStatus()` matcher that does
the same thing.

Future CLs will update other uses of DecodeStatus to do it more
properly, and not rely on this somewhat hacky enum-merging.  It can
be done incrementally with these changes, which is the real goal.

Change-Id: I77dd3ee9e3be5b17ca070e602f2b173ba98d4694
Bug: 1129662
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392950
Reviewed-by: Sergey Volk <servolk@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810257}
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 25717ca..7772462 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -136,9 +136,8 @@
   }
 
   // Decode |buffer| and expect DecodeDone to get called with |status|.
-  void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer,
-                       DecodeStatus status) {
-    EXPECT_CALL(*this, DecodeDone(status));
+  void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer, StatusCode status) {
+    EXPECT_CALL(*this, DecodeDone(HasStatusCode(status)));
     decoder_->Decode(buffer, base::Bind(&DecryptingAudioDecoderTest::DecodeDone,
                                         base::Unretained(this)));
     base::RunLoop().RunUntilIdle();
@@ -247,7 +246,7 @@
   }
 
   MOCK_METHOD1(FrameReady, void(scoped_refptr<AudioBuffer>));
-  MOCK_METHOD1(DecodeDone, void(DecodeStatus));
+  MOCK_METHOD1(DecodeDone, void(Status));
 
   MOCK_METHOD1(OnWaiting, void(WaitingReason));
 
@@ -414,7 +413,7 @@
   EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
       .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_));
   EXPECT_CALL(*this, FrameReady(decoded_frame_));
-  EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK));
+  EXPECT_CALL(*this, DecodeDone(IsOkStatus()));
   event_cb_.Run(CdmContext::Event::kHasAdditionalUsableKey);
   base::RunLoop().RunUntilIdle();
 }
@@ -428,7 +427,7 @@
   EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _))
       .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, decoded_frame_list_));
   EXPECT_CALL(*this, FrameReady(decoded_frame_));
-  EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK));
+  EXPECT_CALL(*this, DecodeDone(IsOkStatus()));
   // The audio decode callback is returned after the correct decryption key is
   // added.
   event_cb_.Run(CdmContext::Event::kHasAdditionalUsableKey);
@@ -457,7 +456,7 @@
   Initialize();
   EnterPendingDecodeState();
 
-  EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
+  EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
 
   Reset();
 }
@@ -467,7 +466,7 @@
   Initialize();
   EnterWaitingForKeyState();
 
-  EXPECT_CALL(*this, DecodeDone(DecodeStatus::ABORTED));
+  EXPECT_CALL(*this, DecodeDone(HasStatusCode(StatusCode::kAborted)));
 
   Reset();
 }