[WebMIDI] Detach clients in MidiService::Shutdown

MidiService::Shutdown clears the |manager_| pointer but doesn't directly
destroy MidiManager. Clients cannot call EndSession and remove themselves
from the |clients_| list in MidiManager (because MidiService no longer owns
it). These clients then can be independently destroyed, leading to a use
after free when MidiManager tries to call Detach on the clients.

Bug: 915693, 913270, 582328
Change-Id: I0f713743bfd8f736c17e3ec3dd8472bd05ad7254
Reviewed-on: https://chromium-review.googlesource.com/c/1383436
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618906}
3 files changed