Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Unified Diff: media/base/android/media_codec_loop.h

Issue 2132653002: MediaCodecLoop unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added some tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/media_codec_loop.h
diff --git a/media/base/android/media_codec_loop.h b/media/base/android/media_codec_loop.h
index 6889f8e0c407c5661e41fe983fc4fdfabf9a7b21..6201414fa1310ccfca7014778d3aee0136f33e77 100644
--- a/media/base/android/media_codec_loop.h
+++ b/media/base/android/media_codec_loop.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "media/base/android/media_codec_bridge.h"
@@ -192,9 +193,17 @@ class MEDIA_EXPORT MediaCodecLoop {
// We will take ownership of |media_codec|. We will not destroy it until
// we are destructed. |media_codec| may not be null.
- MediaCodecLoop(Client* client, std::unique_ptr<MediaCodecBridge> media_codec);
+ MediaCodecLoop(Client* client,
+ std::unique_ptr<MediaCodecBridge> media_codec,
+ scoped_refptr<base::SingleThreadTaskRunner> =
+ scoped_refptr<base::SingleThreadTaskRunner>());
~MediaCodecLoop();
+ // Optionally set the tick clock used for testing. It is our caller's
+ // responsibility to maintain ownership of this, since
+ // FakeSingleThreadTaskRunner maintains a raw ptr to it also.
+ void SetTestTickClock(base::TickClock* test_tick_clock);
+
// Does the MediaCodec processing cycle: enqueues an input buffer, then
// dequeues output buffers. This should be called by the client when more
// work becomes available, such as when new input data arrives. If codec
@@ -266,10 +275,6 @@ class MEDIA_EXPORT MediaCodecLoop {
// A helper function for logging.
static const char* AsString(State state);
- // Used to post tasks. This class is single threaded and every method should
- // run on this task runner.
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
-
State state_;
// The client that we notify about MediaCodec events.
@@ -297,6 +302,10 @@ class MEDIA_EXPORT MediaCodecLoop {
// arrives at the output queue. This is valid when we're in STATE_DRAINING.
DecodeCB pending_eos_completion_cb_;
+ // Optional clock for use during testing. It may be null. We do not maintain
+ // ownership of it.
+ base::TickClock* test_tick_clock_ = nullptr;
+
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<MediaCodecLoop> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698