Fix AudioFocusDelegateDefault behavior
This was revealed by https://chromium-review.googlesource.com/c/chromium/src/+/1145692 which makes subtle changes to Mojo message dispatch timing and can thus expose incorrect assumptions in various bits of code. In this case, there is a race between AbandonAudioFocus and receiving a reply from a previous call to RequestAudioFocus on the audio_focus_ptr_. The callback which handles the latter reply DCHECKs that request_client_ptr_ is bound, but it's possible for AbandonAudioFocus to have been called before that reply is dispatched. The above Mojo CL in question causes some unit tests to flake by hitting this DCHECK occasionally. This CL corrects the issue by also resetting audio_focus_ptr_ in AbandonAudioFocus, which ensures that any pending replies on that interface will *not* be dispatched. This also fixes a bug in AudioFocusManagerMetricsHelper (also revealed by this CL) where it was retaining a *reference* to an unowned std::string that could be deleted before the helper. This is because the string was ultimately owned by a binding endpooint, but the helper is owned by a StackRow which can outlive any given binding endpoint. Because the name is effectively only useful at helper construction time, this simply changes the helper to retain a copy instead of a reference. TBR=mlamouri@chromium.org Bug: 895693 Change-Id: I958b783d005cb85dc9dc9f7371df100883d774cb Reviewed-on: https://chromium-review.googlesource.com/c/1286202 Commit-Queue: Ken Rockot <rockot@google.com> Reviewed-by:Becca Hughes <beccahughes@chromium.org> Cr-Commit-Position: refs/heads/master@{#601362}
Showing
Please register or sign in to comment