Manage MIDI related objects and sessions' lifecycles correctly
Following changes are needed to maintain MIDIPortInfoList contents
consistent in each MidiMessageFilter instances when MidiManager
update the list asynchronously.
Essential changes:
- Call EndSession iff a session is open.
- Do not use client_id to communicate between browser and renderer.
Multiple clients are managed in a MidiMessageFilter existing in
each renderer.
Minor changes:
- Remove midi_manager_ checks in MIDIHost, and add CHECK insteads.
- Rename MidiManagerFilter::StartSession to MidiManagerFilter::AddClient
to be aligned with RemoveClient. A session can be shared with multiple
clients.
After this change, MidiManager::EndSession is called from each Renderer
and RendererHost at the right timing, e.g., GC collects the last MIDIAccess
reference in JavaScript. See, also http://crbug.com/424859.
BUG=424859
Review URL: https://codereview.chromium.org/
662853003
Cr-Commit-Position: refs/heads/master@{#300851}