| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..10673a1ab60329a519c5bd322715580a89667c70
|
| --- /dev/null
|
| +++ b/content/renderer/media/midi_message_filter.h
|
| @@ -0,0 +1,87 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
|
| +#define CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "content/common/content_export.h"
|
| +#include "ipc/ipc_channel_proxy.h"
|
| +#include <vector>
|
| +
|
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebMIDIAccessor.h"
|
| +
|
| +namespace base {
|
| +class MessageLoopProxy;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +// MessageFilter that handles MIDI messages.
|
| +class CONTENT_EXPORT MIDIMessageFilter
|
| + : public IPC::ChannelProxy::MessageFilter {
|
| + public:
|
| + explicit MIDIMessageFilter(
|
| + const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
|
| +
|
| + // Getter for the one MIDIMessageFilter object.
|
| + static MIDIMessageFilter* Get();
|
| +
|
| + // IO message loop associated with this message filter.
|
| + scoped_refptr<base::MessageLoopProxy> io_message_loop() const {
|
| + return io_message_loop_;
|
| + }
|
| +
|
| + void AddClient(WebKit::WebMIDIAccessor::Client* client);
|
| + void RemoveClient(WebKit::WebMIDIAccessor::Client* client);
|
| +
|
| + protected:
|
| + virtual ~MIDIMessageFilter();
|
| +
|
| + private:
|
| + // Sends an IPC message using |channel_|.
|
| + void Send(IPC::Message* message);
|
| +
|
| + // IPC::ChannelProxy::MessageFilter override. Called on |io_message_loop|.
|
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
| + virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
|
| + virtual void OnFilterRemoved() OVERRIDE;
|
| + virtual void OnChannelClosing() OVERRIDE;
|
| +
|
| + // Called when browser process has approved (or denied)
|
| + // access to MIDI hardware.
|
| + void OnAccessApproved(int access, bool success);
|
| +
|
| + // Called when the browser process has sent MIDI data containing one or
|
| + // more messages.
|
| + void OnDataReceived(int port,
|
| + const std::vector<uint8>& data,
|
| + double timestamp);
|
| +
|
| +
|
| +
|
| + void HandleDataReceived(int port,
|
| + const std::vector<uint8>& data,
|
| + double timestamp);
|
| +
|
| +
|
| + // IPC channel for Send(); must only be accesed on |io_message_loop_|.
|
| + IPC::Channel* channel_;
|
| +
|
| + // Message loop on which IPC calls are driven.
|
| + const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
|
| +
|
| + // The singleton instance for this filter.
|
| + static MIDIMessageFilter* g_filter;
|
| +
|
| + WebKit::WebMIDIAccessor::Client* client_;
|
| + // For main thread!!!!!!!!!!
|
| + base::MessageLoop* message_loop_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MIDIMessageFilter);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_MEDIA_MIDI_MESSAGE_FILTER_H_
|
|
|