Web MIDI: MidiManager crashes if a session is ended while initializing

If a MidiManagerClient was destructed while an asynchronous MidiManager
initialization performs, the browser process crashes when the
initilization is finished. On EndSession(), MidiManager should remove
the client even from |pending_clients_|.

Also, this change fixes a problem that CompleteStartSession() may not be
invoked on a MidiManagerClient if its |client_id| is confclicting with
another MidiManagerClient.

BUG=382522
TEST=media_unittests --gtest_filter='Midi*'

Review URL: https://codereview.chromium.org/323323002

Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8b055378f2640dfc13f42d1d4edbe80f5aa771d8
diff --git a/midi_manager.h b/midi_manager.h
index f6c424b..9fd7a21 100644
--- a/midi_manager.h
+++ b/midi_manager.h
@@ -152,7 +152,7 @@
   ClientList clients_;
 
   // Keeps track of all clients who are waiting for CompleteStartSession().
-  typedef std::map<int, MidiManagerClient*> PendingClientMap;
+  typedef std::multimap<MidiManagerClient*, int> PendingClientMap;
   PendingClientMap pending_clients_;
 
   // Keeps a SingleThreadTaskRunner of the thread that calls StartSession in