Commit 2482aae1 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

Ensure VideoCaptureSystem is deleted on the right thread

InProcessVideoCaptureProvider uses VideoCaptureSystem on a separate
device thread, but it was deleting it on the IO browser thread. Fixed
InProcessVideoCaptureProvider to delete VideoCaptureSystem on the same
thread on which it's being used.

Bug: 1127447
Change-Id: Ibf867acea96a28dd992ae9d1139a5ec162d8ee8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427031
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811551}
parent e74d8ca8
...@@ -23,6 +23,11 @@ InProcessVideoCaptureProvider::InProcessVideoCaptureProvider( ...@@ -23,6 +23,11 @@ InProcessVideoCaptureProvider::InProcessVideoCaptureProvider(
InProcessVideoCaptureProvider::~InProcessVideoCaptureProvider() { InProcessVideoCaptureProvider::~InProcessVideoCaptureProvider() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (video_capture_system_ && !device_task_runner_->BelongsToCurrentThread()) {
device_task_runner_->DeleteSoon(FROM_HERE,
std::move(video_capture_system_));
}
} }
// static // static
......
...@@ -38,7 +38,7 @@ class CONTENT_EXPORT InProcessVideoCaptureProvider ...@@ -38,7 +38,7 @@ class CONTENT_EXPORT InProcessVideoCaptureProvider
private: private:
// Can be nullptr. // Can be nullptr.
const std::unique_ptr<media::VideoCaptureSystem> video_capture_system_; std::unique_ptr<media::VideoCaptureSystem> video_capture_system_;
// The message loop of media stream device thread, where VCD's live. // The message loop of media stream device thread, where VCD's live.
const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
base::RepeatingCallback<void(const std::string&)> emit_log_message_cb_; base::RepeatingCallback<void(const std::string&)> emit_log_message_cb_;
......
...@@ -280,7 +280,7 @@ class VideoCaptureManagerTest : public testing::Test { ...@@ -280,7 +280,7 @@ class VideoCaptureManagerTest : public testing::Test {
ASSERT_GE(devices_.size(), 2u); ASSERT_GE(devices_.size(), 2u);
} }
void TearDown() override {} void TearDown() override { task_environment_.RunUntilIdle(); }
void OnGotControllerCallback( void OnGotControllerCallback(
VideoCaptureControllerID id, VideoCaptureControllerID id,
...@@ -348,12 +348,12 @@ class VideoCaptureManagerTest : public testing::Test { ...@@ -348,12 +348,12 @@ class VideoCaptureManagerTest : public testing::Test {
} }
#endif #endif
BrowserTaskEnvironment task_environment_;
ScreenlockMonitorTestSource* screenlock_monitor_source_; ScreenlockMonitorTestSource* screenlock_monitor_source_;
std::unique_ptr<ScreenlockMonitor> screenlock_monitor_; std::unique_ptr<ScreenlockMonitor> screenlock_monitor_;
std::map<VideoCaptureControllerID, VideoCaptureController*> controllers_; std::map<VideoCaptureControllerID, VideoCaptureController*> controllers_;
scoped_refptr<VideoCaptureManager> vcm_; scoped_refptr<VideoCaptureManager> vcm_;
std::unique_ptr<MockMediaStreamProviderListener> listener_; std::unique_ptr<MockMediaStreamProviderListener> listener_;
BrowserTaskEnvironment task_environment_;
std::unique_ptr<MockFrameObserver> frame_observer_; std::unique_ptr<MockFrameObserver> frame_observer_;
WrappedDeviceFactory* video_capture_device_factory_; WrappedDeviceFactory* video_capture_device_factory_;
blink::MediaStreamDevices devices_; blink::MediaStreamDevices devices_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment