| Index: content/renderer/media/midi_message_filter.h
|
| diff --git a/content/renderer/media/midi_message_filter.h b/content/renderer/media/midi_message_filter.h
|
| index 4aa560aa0972b8ae6999a92be3d7387f14822812..34cee3d1c26a59f44b9b3cc17e9f03835d203a7a 100644
|
| --- a/content/renderer/media/midi_message_filter.h
|
| +++ b/content/renderer/media/midi_message_filter.h
|
| @@ -5,7 +5,7 @@
|
| #ifndef CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
|
| #define CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
|
|
|
| -#include <map>
|
| +#include <set>
|
| #include <vector>
|
|
|
| #include "base/memory/scoped_ptr.h"
|
| @@ -29,9 +29,7 @@ class CONTENT_EXPORT MidiMessageFilter : public IPC::MessageFilter {
|
|
|
| // Each client registers for MIDI access here.
|
| // If permission is granted, then the client's
|
| - // addInputPort() and addOutputPort() methods will be called,
|
| - // giving the client access to receive and send data.
|
| - void StartSession(blink::WebMIDIAccessorClient* client);
|
| + void AddClient(blink::WebMIDIAccessorClient* client);
|
| void RemoveClient(blink::WebMIDIAccessorClient* client);
|
|
|
| // A client will only be able to call this method if it has a suitable
|
| @@ -50,6 +48,14 @@ class CONTENT_EXPORT MidiMessageFilter : public IPC::MessageFilter {
|
| ~MidiMessageFilter() override;
|
|
|
| private:
|
| + void StartSessionOnIOThread();
|
| +
|
| + void SendMidiDataOnIOThread(uint32 port,
|
| + const std::vector<uint8>& data,
|
| + double timestamp);
|
| +
|
| + void EndSessionOnIOThread();
|
| +
|
| // Sends an IPC message using |sender_|.
|
| void Send(IPC::Message* message);
|
|
|
| @@ -61,8 +67,9 @@ class CONTENT_EXPORT MidiMessageFilter : public IPC::MessageFilter {
|
|
|
| // Called when the browser process has approved (or denied) access to
|
| // MIDI hardware.
|
| - void OnSessionStarted(int client_id,
|
| - media::MidiResult result,
|
| + // TODO(toyoshim): MidiPortInfoList objects should be notified separately
|
| + // port by port.
|
| + void OnSessionStarted(media::MidiResult result,
|
| media::MidiPortInfoList inputs,
|
| media::MidiPortInfoList outputs);
|
|
|
| @@ -77,22 +84,14 @@ class CONTENT_EXPORT MidiMessageFilter : public IPC::MessageFilter {
|
| // sending too much data before knowing how much has already been sent.
|
| void OnAcknowledgeSentData(size_t bytes_sent);
|
|
|
| - void HandleSessionStarted(int client_id,
|
| - media::MidiResult result,
|
| - media::MidiPortInfoList inputs,
|
| - media::MidiPortInfoList outputs);
|
| + // Following methods, Handle*, run on |main_message_loop_|.
|
| + void HandleClientAdded(media::MidiResult result);
|
|
|
| void HandleDataReceived(uint32 port,
|
| const std::vector<uint8>& data,
|
| double timestamp);
|
|
|
| - void StartSessionOnIOThread(int client_id);
|
| -
|
| - void SendMidiDataOnIOThread(uint32 port,
|
| - const std::vector<uint8>& data,
|
| - double timestamp);
|
| -
|
| - blink::WebMIDIAccessorClient* GetClientFromId(int client_id);
|
| + void HandleAckknowledgeSentData(size_t bytes_sent);
|
|
|
| // IPC sender for Send(); must only be accessed on |io_message_loop_|.
|
| IPC::Sender* sender_;
|
| @@ -103,15 +102,24 @@ class CONTENT_EXPORT MidiMessageFilter : public IPC::MessageFilter {
|
| // Main thread's message loop.
|
| scoped_refptr<base::MessageLoopProxy> main_message_loop_;
|
|
|
| + /*
|
| + * Notice: Following members are designed to be accessed only on
|
| + * |main_message_loop_|.
|
| + */
|
| // Keeps track of all MIDI clients.
|
| - // We map client to "client id" used to track permission.
|
| - // When access has been approved, we add the input and output ports to
|
| - // the client, allowing it to actually receive and send MIDI data.
|
| - typedef std::map<blink::WebMIDIAccessorClient*, int> ClientsMap;
|
| - ClientsMap clients_;
|
| -
|
| - // Dishes out client ids.
|
| - int next_available_id_;
|
| + typedef std::set<blink::WebMIDIAccessorClient*> ClientsSet;
|
| + ClientsSet clients_;
|
| +
|
| + // Represents clients that are waiting for a session being open.
|
| + typedef std::vector<blink::WebMIDIAccessorClient*> ClientsQueue;
|
| + ClientsQueue clients_waiting_session_queue_;
|
| +
|
| + // Represents a result on starting a session. Can be accessed only on
|
| + media::MidiResult session_result_;
|
| +
|
| + // Holds MidiPortInfoList for input ports and output ports.
|
| + media::MidiPortInfoList inputs_;
|
| + media::MidiPortInfoList outputs_;
|
|
|
| size_t unacknowledged_bytes_sent_;
|
|
|
|
|