DescriptionReland [Mojo Video Capture] Introduce abstraction VideoCaptureSystem
Link to original CL: https://codereview.chromium.org/2769543002/
PatchSet 1 is state as reviewed previously.
PatchSet 2 applies a fix for the issue described below.
This was reverted because it caused a test flakiness for test
MediaDevicesDispatcherHostTest.GetVideoInputCapabilities on Windows.
Analysis of the issue:
The CL created a race condition that could cause the test method to exit
before the exercise had finished executing. What made the difference is that
VideoCaptureSystem::GetDeviceInfosAsync() invoked by VideoCaptureManager
now actually runs asynchronous, i.e. it posts invocation of its
|result_callback| to the end of a message queue. Before this CL,
VideoCaptureManager directly called
VideoCaptureDeviceFactory::EnumerateDeviceDescriptors which, despite its
asynchronous-looking API invoked its callback synchronously. The test code was
relying on this being the case. After the CL, the following bad sequence could
happen:
1.) Test calls |host_->GetVideoInputCapabilities()| which eventually kicks of
asynchronous work A on the "device thread".
2.) Test method reaches statement
|media_stream_manager_->FlushVideoCaptureThreadForTesting()| and blocks until
the already posted work A on the device thread finishes.
3.) Work A posts new work B to the device thread.
4.) Work A finishes.
5.) FlushVideoCaptureThreadForTesting() returns and the test method exits before
work B has run.
Description of fix:
The way that the test was waiting for the asynchronous exercise to complete was
based on dangerous (and now incorrect) assumptions of how and where the
implementation under test internally posts task. The fix is to eliminate these
assumptions and, instead, block the test method until the waited-for callback
arrives.
Original CL description:
This CL is supposed to be a pure refactoring. There should be no changes to
existing behavior.
This is part of a series of CLs with the goal of separating the class
VideoCaptureManager from knowledge of things that are going to be private
implementation details of the video capture service. The end goal is to have
VideoCaptureManager talk to an abstraction that can be implemented by either the
video capture Mojo service or the existing (legacy) in-process implementation.
Changes in this CL:
* Move nested struct VideoCaptureManager::DeviceInfo to struct
media::VideoCaptureDeviceInfo.
* Create abstraction VideoCaptureSystem and move caching of
VideoCaptureDeviceInfo to there. This allows us to use this functionality in
both InProcess and MojoService code paths.
* Simplify BuildableDeviceCallbacks interface. With the mapping from device_id
to descriptor being moved into VideoCaptureSystem, BuildableDeviceCallbacks no
longer needs to offer a LookupDeviceDescriptor() method.
This CL is part of the Mojo Video Capture work. For the bigger picture,
see [1] CL18.
BUG=584797
TEST=
content_unittests --gtest_filter="*Video*"
content_browsertests --gtest_filter="VideoCaptureBrowserTest.*"
[1] https://docs.google.com/a/chromium.org/document/d/1Qw7rw1AJy0QHXjha36jZNiEuxsxWslJ_X-zpOhijvI8/edit?usp=sharing
Review-Url: https://codereview.chromium.org/2805533002
Cr-Commit-Position: refs/heads/master@{#462916}
Committed: https://chromium.googlesource.com/chromium/src/+/8927c43c9dfd0fa73d092eea903f9f3a1f3292f1
Patch Set 1 : State as reviewed previously #Patch Set 2 : Fix race condition in tests #
Total comments: 3
Dependent Patchsets: Messages
Total messages: 20 (11 generated)
|