Index: media/capture/video/linux/v4l2_capture_delegate.cc |
diff --git a/media/capture/video/linux/v4l2_capture_delegate.cc b/media/capture/video/linux/v4l2_capture_delegate.cc |
index 2f16c203996b82851c6181e67ac4a3f07b96c8a6..6c765226b6d8dddc0d88f774853300290a12a413 100644 |
--- a/media/capture/video/linux/v4l2_capture_delegate.cc |
+++ b/media/capture/video/linux/v4l2_capture_delegate.cc |
@@ -374,7 +374,8 @@ V4L2CaptureDelegate::V4L2CaptureDelegate( |
power_line_frequency_(power_line_frequency), |
is_capturing_(false), |
timeout_count_(0), |
- rotation_(0) {} |
+ rotation_(0), |
+ weak_factory_(this) {} |
void V4L2CaptureDelegate::AllocateAndStart( |
int width, |
@@ -506,7 +507,7 @@ void V4L2CaptureDelegate::AllocateAndStart( |
// Post task to start fetching frames from v4l2. |
v4l2_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this)); |
+ FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, GetWeakPtr())); |
} |
void V4L2CaptureDelegate::StopAndDeAllocate() { |
@@ -714,6 +715,10 @@ void V4L2CaptureDelegate::SetRotation(int rotation) { |
rotation_ = rotation; |
} |
+base::WeakPtr<V4L2CaptureDelegate> V4L2CaptureDelegate::GetWeakPtr() { |
+ return weak_factory_.GetWeakPtr(); |
+} |
+ |
V4L2CaptureDelegate::~V4L2CaptureDelegate() {} |
bool V4L2CaptureDelegate::MapAndQueueBuffer(int index) { |
@@ -820,7 +825,7 @@ void V4L2CaptureDelegate::DoCapture() { |
} |
v4l2_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, this)); |
+ FROM_HERE, base::Bind(&V4L2CaptureDelegate::DoCapture, GetWeakPtr())); |
} |
void V4L2CaptureDelegate::SetErrorState( |