OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "ipc/ipc_channel_proxy.h" |
| 11 #include <vector> |
| 12 |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMIDIAccessor.h" |
| 14 |
| 15 namespace base { |
| 16 class MessageLoopProxy; |
| 17 } |
| 18 |
| 19 namespace content { |
| 20 |
| 21 // MessageFilter that handles MIDI messages. |
| 22 class CONTENT_EXPORT MIDIMessageFilter |
| 23 : public IPC::ChannelProxy::MessageFilter { |
| 24 public: |
| 25 explicit MIDIMessageFilter( |
| 26 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| 27 |
| 28 // Getter for the one MIDIMessageFilter object. |
| 29 static MIDIMessageFilter* Get(); |
| 30 |
| 31 // IO message loop associated with this message filter. |
| 32 scoped_refptr<base::MessageLoopProxy> io_message_loop() const { |
| 33 return io_message_loop_; |
| 34 } |
| 35 |
| 36 void AddClient(WebKit::WebMIDIAccessor::Client* client); |
| 37 void RemoveClient(WebKit::WebMIDIAccessor::Client* client); |
| 38 |
| 39 protected: |
| 40 virtual ~MIDIMessageFilter(); |
| 41 |
| 42 private: |
| 43 // Sends an IPC message using |channel_|. |
| 44 void Send(IPC::Message* message); |
| 45 |
| 46 // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|. |
| 47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 48 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
| 49 virtual void OnFilterRemoved() OVERRIDE; |
| 50 virtual void OnChannelClosing() OVERRIDE; |
| 51 |
| 52 // Called when browser process has approved (or denied) |
| 53 // access to MIDI hardware. |
| 54 void OnAccessApproved(int access, bool success); |
| 55 |
| 56 // Called when the browser process has sent MIDI data containing one or |
| 57 // more messages. |
| 58 void OnDataReceived(int port, |
| 59 const std::vector<uint8>& data, |
| 60 double timestamp); |
| 61 |
| 62 |
| 63 |
| 64 void HandleDataReceived(int port, |
| 65 const std::vector<uint8>& data, |
| 66 double timestamp); |
| 67 |
| 68 |
| 69 // IPC channel for Send(); must only be accesed on |io_message_loop_|. |
| 70 IPC::Channel* channel_; |
| 71 |
| 72 // Message loop on which IPC calls are driven. |
| 73 const scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 74 |
| 75 // The singleton instance for this filter. |
| 76 static MIDIMessageFilter* g_filter; |
| 77 |
| 78 WebKit::WebMIDIAccessor::Client* client_; |
| 79 // For main thread!!!!!!!!!! |
| 80 base::MessageLoop* message_loop_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(MIDIMessageFilter); |
| 83 }; |
| 84 |
| 85 } // namespace content |
| 86 |
| 87 #endif // CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_ |
OLD | NEW |