• Jinsuk Kim's avatar
    Android: Ensure |OnDetachedFromWindow| is invoked upon destruction · 712b2013
    Jinsuk Kim authored
    https://crrev.com/c/1020942 meant to make sure |DetachedFromWindow| is
    invoked upon ViewAndroid destruction. This had a bug when
    WindowAndroid is destroyed first, which can happen for Chromecast
    where WebContents destruction is delayed by design.
    
    WindowAndroid dtor invokes |GetWindowAndroid| indirectly via its
    base dtor (through RemoveAllChildren), but it didn't work as intended
    because |GetWindowAndroid| is a virtual function. So it ended up
    calling |ViewAndroid::GetWindowAndroid|, not
    |WindowAndroid::GetWindowAndroid|.
    
    This CL fixes it by pulling out the task of invoking
    |OnDetachedFromWindow| so that the destructor won't use the virtual
    function. WindowAndroid can call |OnDetachedFromWindow| in its dtor
    since it doesn't need |GetWindowAndroid| - it knows for sure
    WindowAndroid (itself) is present.
    
    
    Bug: b/78251221
    Change-Id: I754e45ca3ea61ceb86101ede3b529e75e206689f
    Reviewed-on: https://chromium-review.googlesource.com/1102823
    Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
    Reviewed-by: default avatarBo <boliu@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#568064}
    712b2013
view_android.cc 19.4 KB