media: Add DeferredDestroyStrongBindingSet
This CL adds DeferredDestroyStrongBindingSet such that mojom::Foo impl will only be destroyed when: - mojom::Foo connection error happens, AND FooImpl calls the DestroyCallback, or - DeferredDestroyStrongBindingSet is destroyed. This helps solve tricky lifetime issues where we do not want destroy the implementation immediately. For example, currently when connection error on mojom::CdmFactory happens, CdmFactoryImpl will be destroyed, which will also destroy all CDMs owned by CdmFactoryImpl. However, this could happen before MojoCdm is stopped in the render process, causing unexpected behavior. See the bug for more details. This CL also fixes the CdmFactoryImpl lifetime issue by using the DeferredDestroyStrongBindingSet, and let CdmFactoryImpl only call the DestroyCallback when no outstanding CDMs exist. For historical context, mojo::StrongBindingSet was originally added also to solve lifetime issues around media::mojom::InterfaceFactory, the predecessor of media::mojom::CdmFactory. See https://codereview.chromium.org/2530613003/. Bug: 821171 Test: Added new BindingSetTest cases. Change-Id: I24a660e8b62720f7fd772db1bafb9499cb71428c Reviewed-on: https://chromium-review.googlesource.com/969655 Commit-Queue: Xiaohan Wang <xhwang@chromium.org> Reviewed-by:Ken Rockot <rockot@chromium.org> Reviewed-by:
Frank Liberato <liberato@chromium.org> Cr-Commit-Position: refs/heads/master@{#548704}
Showing
Please register or sign in to comment