Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Unified Diff: content/renderer/media/midi_message_filter.cc

Issue 664843002: Web MIDI: distributes MIDIPort information asynchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lifecycle
Patch Set: typo on ipc Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/midi_message_filter.h ('k') | media/midi/midi_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/midi_message_filter.cc
diff --git a/content/renderer/media/midi_message_filter.cc b/content/renderer/media/midi_message_filter.cc
index 27fe2a72fa63d74e239f4ff7d5abe2298a63fa48..fb9dbd611382787d55f174cae7aa6ca0b6e74fad 100644
--- a/content/renderer/media/midi_message_filter.cc
+++ b/content/renderer/media/midi_message_filter.cc
@@ -60,6 +60,8 @@ void MidiMessageFilter::RemoveClient(blink::WebMIDIAccessorClient* client) {
clients_waiting_session_queue_.erase(it);
if (clients_.empty() && clients_waiting_session_queue_.empty()) {
session_result_ = media::MIDI_NOT_INITIALIZED;
+ inputs_.clear();
+ outputs_.clear();
io_message_loop_->PostTask(FROM_HERE,
base::Bind(&MidiMessageFilter::EndSessionOnIOThread, this));
}
@@ -125,6 +127,8 @@ bool MidiMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(MidiMessageFilter, message)
IPC_MESSAGE_HANDLER(MidiMsg_SessionStarted, OnSessionStarted)
+ IPC_MESSAGE_HANDLER(MidiMsg_AddInputPort, OnAddInputPort)
+ IPC_MESSAGE_HANDLER(MidiMsg_AddOutputPort, OnAddOutputPort)
IPC_MESSAGE_HANDLER(MidiMsg_DataReceived, OnDataReceived)
IPC_MESSAGE_HANDLER(MidiMsg_AcknowledgeSentData, OnAcknowledgeSentData)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -149,15 +153,11 @@ void MidiMessageFilter::OnChannelClosing() {
sender_ = NULL;
}
-void MidiMessageFilter::OnSessionStarted(media::MidiResult result,
- MidiPortInfoList inputs,
- MidiPortInfoList outputs) {
+void MidiMessageFilter::OnSessionStarted(media::MidiResult result) {
TRACE_EVENT0("midi", "MidiMessageFilter::OnSessionStarted");
DCHECK(io_message_loop_->BelongsToCurrentThread());
base::AutoLock auto_lock(lock_);
session_result_ = result;
- inputs_ = inputs;
- outputs_ = outputs;
// Handle on the main JS thread.
for (blink::WebMIDIAccessorClient* client : clients_waiting_session_queue_) {
main_message_loop_->PostTask(FROM_HERE,
@@ -166,6 +166,20 @@ void MidiMessageFilter::OnSessionStarted(media::MidiResult result,
clients_waiting_session_queue_.clear();
}
+void MidiMessageFilter::OnAddInputPort(media::MidiPortInfo info) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ base::AutoLock auto_lock(lock_);
+ inputs_.push_back(info);
+ // TODO(toyoshim): Notify to clients that were already added.
+}
+
+void MidiMessageFilter::OnAddOutputPort(media::MidiPortInfo info) {
+ DCHECK(io_message_loop_->BelongsToCurrentThread());
+ base::AutoLock auto_lock(lock_);
+ outputs_.push_back(info);
+ // TODO(toyoshim): Notify to clients that were already added.
+}
+
void MidiMessageFilter::OnDataReceived(uint32 port,
const std::vector<uint8>& data,
double timestamp) {
« no previous file with comments | « content/renderer/media/midi_message_filter.h ('k') | media/midi/midi_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698