Manage MIDI related objects and sessions' lifecycles correctly
commit71fcb150d9e2cb5e2f05069177ac611ac9c189c0
authortoyoshim <toyoshim@chromium.org>
Thu, 23 Oct 2014 07:17:59 +0000 (23 00:17 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 23 Oct 2014 07:18:17 +0000 (23 07:18 +0000)
tree5067da853f0f8b7d7b52a0fb632ad93e33701fe7
parent7a0ddbb2ced7ed2117ae177773714968f66a66b5
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}
content/browser/media/midi_host.cc
content/browser/media/midi_host.h
content/common/media/midi_messages.h
content/renderer/media/midi_message_filter.cc
content/renderer/media/midi_message_filter.h
content/renderer/media/renderer_webmidiaccessor_impl.cc
media/midi/midi_manager.cc
media/midi/midi_manager.h
media/midi/midi_manager_unittest.cc
media/midi/midi_manager_usb_unittest.cc
media/midi/midi_result.h