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

Unified Diff: content/renderer/media/video_capture_impl.cc

Issue 2377163002: VideoCaptureImpl cleanup: merge ctor+Init() and DeInit()+dtor. (Closed)
Patch Set: miu@s comment on passing |io_task_runner| argument Created 4 years, 3 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
« no previous file with comments | « content/renderer/media/video_capture_impl.h ('k') | content/renderer/media/video_capture_impl_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/video_capture_impl.cc
diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc
index 43d59930d052fecb3d8a48834a2b76c55e060d7e..583fb97bb9e68b9fffc02977cecb96879447632e 100644
--- a/content/renderer/media/video_capture_impl.cc
+++ b/content/renderer/media/video_capture_impl.cc
@@ -105,33 +105,24 @@ VideoCaptureImpl::ClientInfo::ClientInfo(const ClientInfo& other) = default;
VideoCaptureImpl::ClientInfo::~ClientInfo() {}
VideoCaptureImpl::VideoCaptureImpl(
- const media::VideoCaptureSessionId session_id,
- VideoCaptureMessageFilter* filter)
+ media::VideoCaptureSessionId session_id,
+ VideoCaptureMessageFilter* filter,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
: message_filter_(filter),
device_id_(0),
session_id_(session_id),
suspended_(false),
state_(VIDEO_CAPTURE_STATE_STOPPED),
+ io_task_runner_(std::move(io_task_runner)),
weak_factory_(this) {
DCHECK(filter);
+ io_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&VideoCaptureMessageFilter::AddDelegate,
+ message_filter_, this));
}
VideoCaptureImpl::~VideoCaptureImpl() {
DCHECK(io_task_runner_->BelongsToCurrentThread());
-}
-
-void VideoCaptureImpl::Init() {
- // For creating callbacks in unittest, this class may be constructed from a
- // different thread than the IO thread, e.g. wherever unittest runs on.
- // Therefore, this function should define the thread ownership.
-#if DCHECK_IS_ON()
- io_task_runner_ = base::ThreadTaskRunnerHandle::Get();
-#endif
- message_filter_->AddDelegate(this);
-}
-
-void VideoCaptureImpl::DeInit() {
- DCHECK(io_task_runner_->BelongsToCurrentThread());
if (state_ == VIDEO_CAPTURE_STATE_STARTED)
Send(new VideoCaptureHostMsg_Stop(device_id_));
message_filter_->RemoveDelegate(this);
« no previous file with comments | « content/renderer/media/video_capture_impl.h ('k') | content/renderer/media/video_capture_impl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698