Index: content/common/gpu/media/v4l2_video_decode_accelerator.cc |
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
index 992e6afe61942cad230fdd6ada7991d48cba7a2b..68baaa85c845c91dda916e544ddd9e15e27431a3 100644 |
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
@@ -154,7 +154,6 @@ V4L2VideoDecodeAccelerator::PictureRecord::~PictureRecord() {} |
V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator( |
EGLDisplay egl_display, |
- Client* client, |
const base::WeakPtr<Client>& io_client, |
const base::Callback<bool(void)>& make_context_current, |
scoped_ptr<V4L2Device> device, |
@@ -162,8 +161,6 @@ V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator( |
: child_message_loop_proxy_(base::MessageLoopProxy::current()), |
io_message_loop_proxy_(io_message_loop_proxy), |
weak_this_(base::AsWeakPtr(this)), |
- client_ptr_factory_(client), |
- client_(client_ptr_factory_.GetWeakPtr()), |
io_client_(io_client), |
decoder_thread_("V4L2DecoderThread"), |
decoder_state_(kUninitialized), |
@@ -202,12 +199,15 @@ V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() { |
DCHECK(output_buffer_map_.empty()); |
} |
-bool V4L2VideoDecodeAccelerator::Initialize( |
- media::VideoCodecProfile profile) { |
+bool V4L2VideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, |
+ Client* client) { |
DVLOG(3) << "Initialize()"; |
DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
DCHECK_EQ(decoder_state_, kUninitialized); |
+ client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); |
+ client_ = client_ptr_factory_->GetWeakPtr(); |
+ |
switch (profile) { |
case media::H264PROFILE_BASELINE: |
DVLOG(2) << "Initialize(): profile H264PROFILE_BASELINE"; |
@@ -427,7 +427,7 @@ void V4L2VideoDecodeAccelerator::Destroy() { |
DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
// We're destroying; cancel all callbacks. |
- client_ptr_factory_.InvalidateWeakPtrs(); |
+ client_ptr_factory_.reset(); |
// If the decoder thread is running, destroy using posted task. |
if (decoder_thread_.IsRunning()) { |
@@ -1587,7 +1587,7 @@ void V4L2VideoDecodeAccelerator::NotifyError(Error error) { |
if (client_) { |
client_->NotifyError(error); |
- client_ptr_factory_.InvalidateWeakPtrs(); |
+ client_ptr_factory_.reset(); |
} |
} |