Chromium Code Reviews| Index: content/browser/media/midi_host.cc |
| diff --git a/content/browser/media/midi_host.cc b/content/browser/media/midi_host.cc |
| index 1e6de1e234f1b6b5eebdf01a97c68de307b3a139..fe8e2fbdcfb47a64b2c3c93d63874a7e6bc44c6c 100644 |
| --- a/content/browser/media/midi_host.cc |
| +++ b/content/browser/media/midi_host.cc |
| @@ -59,10 +59,19 @@ MidiHost::MidiHost(int renderer_process_id, |
| DCHECK(midi_manager_); |
| } |
| -MidiHost::~MidiHost() { |
| - // Close an open session, or abort opening a session. |
| - if (is_session_requested_ && midi_manager_) |
| +MidiHost::~MidiHost() {} |
|
Adam Goode
2016/01/12 17:36:45
Suggest (C++11 style):
MidiHost::~MidiHost() = de
Oliver Chang
2016/01/12 17:48:55
Done.
|
| + |
| +void MidiHost::OnChannelClosing() { |
| + // If we get here the MidiHost is going to be destroyed soon. Prevent any |
| + // subsequent calls from MidiManager by closing our session. |
| + // If Send() is called from a different thread (e.g. a separate thread owned |
| + // by the MidiManager implementation), it will get posted to the IO thread. |
| + // There is a race condition here if our refcount is 0 and we're about to or |
| + // have already entered OnDestruct(). |
| + if (is_session_requested_ && midi_manager_) { |
| midi_manager_->EndSession(this); |
| + is_session_requested_ = false; |
| + } |
| } |
| void MidiHost::OnDestruct() const { |