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

Unified Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Created 3 years, 11 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/gpu/android_video_decode_accelerator.cc
diff --git a/media/gpu/android_video_decode_accelerator.cc b/media/gpu/android_video_decode_accelerator.cc
index 3d0e4cfad202723f65d976df288d3dc51748af16..e1c0891c56ba9029284ac5035fe29d4301e2a412 100644
--- a/media/gpu/android_video_decode_accelerator.cc
+++ b/media/gpu/android_video_decode_accelerator.cc
@@ -14,7 +14,6 @@
#include "base/bind_helpers.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
@@ -130,6 +129,8 @@ bool ShouldDeferSurfaceCreation(int surface_id, VideoCodec codec) {
// surfaces are released.
class AVDAManager {
public:
+ AVDAManager() {}
+
// Request periodic callback of |avda|->DoIOTask(). Does nothing if the
// instance is already registered and the timer started. The first request
// will start the repeating timer on an interval of DecodePollDelay.
@@ -166,9 +167,6 @@ class AVDAManager {
}
private:
- friend struct base::DefaultLazyInstanceTraits<AVDAManager>;
-
- AVDAManager() {}
~AVDAManager() { NOTREACHED(); }
Mark Mentovai 2017/01/31 21:33:56 You can switch this to the “= delete” form too.
DaleCurtis 2017/01/31 22:04:33 Done.
void RunTimer() {
@@ -206,8 +204,10 @@ class AVDAManager {
DISALLOW_COPY_AND_ASSIGN(AVDAManager);
};
-static base::LazyInstance<AVDAManager>::Leaky g_avda_manager =
- LAZY_INSTANCE_INITIALIZER;
+static AVDAManager* GetManager() {
+ static AVDAManager* manager = new AVDAManager();
+ return manager;
+}
AndroidVideoDecodeAccelerator::BitstreamRecord::BitstreamRecord(
const BitstreamBuffer& bitstream_buffer)
@@ -242,7 +242,7 @@ AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
DCHECK(thread_checker_.CalledOnValidThread());
- g_avda_manager.Get().StopTimer(this);
+ GetManager()->StopTimer(this);
AVDACodecAllocator::Instance()->StopThread(this);
#if defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
@@ -1065,7 +1065,7 @@ void AndroidVideoDecodeAccelerator::ResetCodecState() {
picture_buffer_manager_.CodecChanged(media_codec_.get());
} else {
DVLOG(3) << __func__ << " Deleting the MediaCodec and creating a new one.";
- g_avda_manager.Get().StopTimer(this);
+ GetManager()->StopTimer(this);
ConfigureMediaCodecAsynchronously();
}
}
@@ -1139,7 +1139,7 @@ void AndroidVideoDecodeAccelerator::ActualDestroy() {
// case, the codec will be deleted when it completes once we invalidate all
// our weak refs.
weak_this_factory_.InvalidateWeakPtrs();
- g_avda_manager.Get().StopTimer(this);
+ GetManager()->StopTimer(this);
ReleaseCodec();
// We no longer care about |surface_id|, in case we did before. It's okay
@@ -1334,9 +1334,9 @@ void AndroidVideoDecodeAccelerator::ManageTimer(bool did_work) {
}
if (should_be_running)
- g_avda_manager.Get().StartTimer(this);
+ GetManager()->StartTimer(this);
else
- g_avda_manager.Get().StopTimer(this);
+ GetManager()->StopTimer(this);
}
// static

Powered by Google App Engine
This is Rietveld 408576698