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

Unified Diff: media/capture/video/linux/v4l2_capture_delegate.cc

Issue 2815643002: Make V4L2CaptureDelegate non-ref-counted (Closed)
Patch Set: mcasas@ comment Created 3 years, 8 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/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(
« no previous file with comments | « media/capture/video/linux/v4l2_capture_delegate.h ('k') | media/capture/video/linux/v4l2_capture_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698