• Xiaohan Wang's avatar
    media: Add DeferredDestroyStrongBindingSet · 71511b2c
    Xiaohan Wang authored
    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: default avatarKen Rockot <rockot@chromium.org>
    Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#548704}
    71511b2c
strong_binding_set.h 1.12 KB